Python programming assignment - you need to create a class


Python Programming Assignment -

You first need an abstract base class, called, Account which has the following attributes and methods:

  • accountID: This attribute holds the ID assigned the account , if not provided set to zero.
  • balance: This attribute holds the initial balance of the account, if not provided set to zero.
  • numberDeposit: This attribute holds the number of deposits this month.
  • numberWithdrawals This attribute holds the number of withdrawals this month.
  • annuallnterest: This attribute holds the annual interest rate.
  • monthlyServiceCharges: This attribute holds the monthly service charges of the account.
  • init: An init method that sets the attributes of the class.
  • deposit: An abstract method that accepts an argument for the amount of the deposit. The method should add the argument to the account balance. It should also increment the variable holding the number of deposits.
  • withdraw: An abstract method that accepts an argument for the amount of withdrawal. This methods should subtract the argument from the balance. It should also increment the variable holding the number of withdrawals.
  • calclnterest: An abstract method that updates the balance by calculating the monthly interest earned by the account, and adding this interest to the balance. This is performed by the following formulas: Monthly Interest Rate = Annual Interest Rate / 12, Monthly Interest = Balance * Monthly Interest Rate and Balance = Balance + Monthly Interest.
  • monthlyProc: An abstract method that subtracts the monthly service charges from the balance, calls the calclnteret method, then sets the variables that hold the number of withdrawals, number of deposits, and monthly service charges to zero.
  • str: Through this method, account ID and balance are displayed.

Next, design a savings account class, called SavingsAccount, derived from the generic Account class. The SavingsAccount class should have the following additional members:

  • status: This attribute represent if account is active or inactive.

If the balance of the savings account falls below $3, it becomes inactive (the status member could be a flag variable). No more withdrawal would be made until the balance is raised above $30, at which time the account becomes active again. The savings account class should have the following methods:

  • init: An init method that inherits from the init method of Account class and also sets the status attribute of the class.
  • deposit: A method that checks if the account is inactive before a deposit is made. If the account is inactive the deposit brings the balance above $30, the account becomes active again. The deposit is then made by calling the base class version of the method.
  • withdraw: A method that checks to see if the account is inactive before a withdrawal is made. No withdrawal is made if the account is inactive. A withdrawals is then made by calling the base class version of the method.
  • monthlyProc: Before the base class method is called, this method checks the number of withdrawal. If the number of withdrawals for the month is more than 4, then a service charge of $2 for each withdrawals above 4 is added to the base class variable that holds the monthly service charges. Don't forget to check the account balance after the service charges are taken. If the balance falls below $30, the account becomes inactive.
  • str: This method prints the account ID, balance, and status.

Next, design a checking account class, also derived from the generic Account class. It should have the following member functions:

  • withdraw: Before the base class method is called, this method will determine if withdrawal will cause the balance falls below $0. If the balance goes below $0, a service charge of $20 will be taken from the account and no withdrawal would be made. If there is not enough to pay the account charges, the balance will become negative and the customer will owe the negative amount to the bank.
  • monthlyProc: Before the base class method is called, this function adds the monthly fee of $5 per withdrawals to the base class variable that holds the monthly service charges.

In the Main.py file, write a complete main function that demonstrates these classes by asking the user to enter the accounts of deposits and withdrawals for a savings and checking account. The program should display statistics for the month, including the beginning balance, total amount of deposits, total amount of withdrawals, service charges and ending balance.

NOTE: You may need t add more member variables and functions to the class than those listed above.

1) You need to create a class variable and assign an initial value of zero to it and update it throughout your program.

2) Yes, it should be decreased meaning that the account holder owes the bank.

3) You don't need to specify a timeline, all transactions assumed to be for the current month and you need to calculate that.

Solution Preview :

Prepared by a verified Expert
Python Programming: Python programming assignment - you need to create a class
Reference No:- TGS02917653

Now Priced at $40 (50% Discount)

Recommended (91%)

Rated (4.3/5)