Design an abstract class named BankAccount to hold the following

Added on - 13 Sep 2019

  • 2

    pages

  • 552

    words

  • 87

    views

  • 0

    downloads

Showing pages 1 to 1 of 2 pages
Design an abstract class namedBankAccountto hold the following data for a bank account:BalanceNumber of deposits this monthNumber of withdrawalsAnnual interest rateMonthly service chargesThe class should have the following methods:Constructor:The constructor should accept arguments for the balance and annual interest ratedeposit:A method that accepts an argument for the amount of deposit. The method shouldadd the argument to the account balance. It should also increment the variable holding thenumber of deposits.withdraw:A method that accepts an argument for the amount of the withdrawal. Themethod should subtract the argument from the balance. It should also increment the variableholding the number of withdrawals.calcInterest:A method that updates the balance by calculating the monthly interestearned by the account, and adding this interest to the balance. This is performed by the followingformulas:Monthly Interest Rate = (Annual Interest Rate/12)Monthly Interest = Balance * Monthly Interest RateBalance = Balance + Monthly InterestmonthlyProcess:A method that subtracts the monthly service charges from the balance,calls thecalcInterestmethod, and then sets the variable les that hold the number ofwithdrawals, number of deposits and monthly service charge to zero.Next, design aSavingAccountclass that is a subclass of theBankAccountclass.TheSavingAccountclass should have a status field to represent an active or inactiveaccount. If the balance of a savings account falls below$25, it becomes inactive. (The status fieldcould be a Boolean variable.) No more withdrawals can be made until the balance is raised above$25, at which time the account becomes active again. Thesavings account class should have thefollowing methods:withdraw:A method that determines whether the account is inactive before a withdrawal ismade. No withdrawal will be allowed if the account is not active. A withdrawal is then made bycalling the super-class version of the method.deposit:A method that determines whether the account is inactive before a deposit ismade. If the account is inactive and the deposit brings the balance above $25, the accountbecomes active again. The deposit is then made by calling the super-class version of the method.monthlyProcess:Before the super-class method is called, this method checks the numberof withdrawals. If the number of withdrawals for the month is more than 4, a service charge of$1 for each withdrawal above 4 is added to the super-class fields that holds the monthly service
desklib-logo
You’re reading a preview
card-image

To View Complete Document

Become a Desklib Library Member.
Subscribe to our plans

Unlock This Document