Menu

[Solved]Java 9 Bankaccount Savingsaccount Classes Design Abstract Class Named Bankaccount Hold Fol Q37221496

JAVA

9. BankAccount and SavingsAccount Classes Design an abstractclass named BankAccount to hold the following data for a bankaccount:

• Balance

• Number of deposits this month

• Number of withdrawals

• Annual interest rate

The class should have the following methods:

Constructor:

The constructor should accept arguments for the balance andannual interest rate.

deposit:

A method that accepts an argument for the amount of the deposit.The method should add the argument to the account balance. Itshould also increment the variable holding the number ofdeposits.

withdraw:

A method that accepts an argument for the amount of thewithdrawal. The method should subtract the argument from thebalance. It should also increment the variable holding the numberof withdrawals.

calcInterest:

A method that updates the balance by calculating the monthlyinter-est earned by the account, and adding this interest to thebalance. This is performed by the following formulas:

Monthly Interest Rate = (Annual Interest Rate / 12)

Monthly Interest = Balance * Monthly Interest Rate

Balance = Balance + Monthly Interest

monthlyProcess: A method that calls thecalcInterest method, and then sets the variables that hold thenumber of withdrawals, number of deposits to zero.

Next, design a SavingsAccount class that extends the BankAccountclass. The SavingsAccount class should have a status field torepresent an active or inactive account. If the balance of asavings account falls below $25, it becomes inactive. (The statusfield could be a boolean variable.) No more withdrawals may be madeuntil the balance is raised above $25, at which time the accountbecomes active again.

The savings account class should have the following methods:

withdraw: A method that determines whether theaccount is inactive before a withdrawal is made. (No withdrawalwill be allowed if the account is not active.) A withdrawal is thenmade by calling the superclass version of the method.

After the superclass method is called, this method checks thenum-ber of withdrawals. If the number of withdrawals for the monthis more than 4, a service charge of $1 for each withdrawal above 4is from the balance. (Don’t forget to check the account balanceafter the service charge is taken. If the balance falls below $25,the account becomes inactive.)

deposit: A deposit is then made by calling thesuperclass version of the method. If the account is inactive andthe deposit brings the balance above $25, the account becomesactive again.

monthlyProcess:

Calls the super class monthly process and displays the finalbalance.

Please make sure that your classes throw appropriateexceptions when an attempt is made to insert invaliddata.

Please check the Test cases for more information onrequirements and input/output message format.

Plase note that the test input that your program will betested might be different from the ones shown below. For exact testinput data, please refer to test cases in mimir.

Test Case1(Testing Validations):

Enter beginning balance :$1000
Enter interest rate(whole number) :%9
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
X
Invalid choice. Try again

Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
D
Enter the amount you want to Deposit :$-1
Error: Must enter positive value

Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
W
Enter the amount you want to withdraw :$-1
Error: Must enter positive value

Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
B
Your Balance is: 1000.00
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
M
Your Balance after Monthly process is: 1007.50
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
E
Balance : $1007.50
Thank you. Bye

Test Case2(Testing Deposit functionality):

Enter beginning balance :$100
Enter interest rate(whole number) :%9
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
D
Enter the amount you want to Deposit :$10
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
D
Enter the amount you want to Deposit :$10
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
D
Enter the amount you want to Deposit :$100
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
D
Enter the amount you want to Deposit :$500
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
D
Enter the amount you want to Deposit :$600
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
B
Your Balance is: 1320.00
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
M
Your Balance after Monthly process is: 1329.90
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
E
Balance : $1329.90
Thank you. Bye

Test Case3(Testing Withdrawal. Please study this indetail and pay attention to minute details):

Enter beginning balance :$100
Enter interest rate(whole number) :%9
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
D
Enter the amount you want to Deposit :$100
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
W
Enter the amount you want to withdraw :$20
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
W
Enter the amount you want to withdraw :$20
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
W
Enter the amount you want to withdraw :$20
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
W
Enter the amount you want to withdraw :$20
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
B
Your Balance is: 120.00
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
W
Enter the amount you want to withdraw :$80
You have exceeded monthly limit of withdrawals. Fee of $1charged

Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
B
Your Balance is: 39.00
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
W
Enter the amount you want to withdraw :$15
Your balance is less than minimum balance. Your account is nowINACTIVE
You have exceeded monthly limit of withdrawals. Fee of $1charged

Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
B
Your Balance is: 23.00
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
D
Enter the amount you want to Deposit :$3
Your account is now ACTIVE

Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
B
Your Balance is: 26.00
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
W
Enter the amount you want to withdraw :$1
Your balance is less than minimum balance. Your account is nowINACTIVE
You have exceeded monthly limit of withdrawals. Fee of $1charged

Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
B
Your Balance is: 24.00
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
D
Enter the amount you want to Deposit :$10
Your account is now ACTIVE

Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
B
Your Balance is: 34.00
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
W
Enter the amount you want to withdraw :$5
You have exceeded monthly limit of withdrawals. Fee of $1charged

Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
B
Your Balance is: 28.00
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
D
Enter the amount you want to Deposit :$100
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
D
Enter the amount you want to Deposit :$1000
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
M
Your Balance after Monthly process is: 1136.46
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
E
Balance : $1136.46
Thank you. Bye

Test Case 4(Validation)

Enter beginning balance :$1000
Enter interest rate(whole number) :%9
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
W
Enter the amount you want to withdraw :$1200
ERROR: Transaction declined!! This transaction will cause overdraftor zero balance
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
B
Your Balance is: 1000.00
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit
M
Your Balance after Monthly process is: 1007.50
Enter D to deposit
Enter W to Withdraw
Enter B for Balance
Enter M for Monthly Process
Enter E to Exit

Expert Answer


Answer to JAVA 9. BankAccount and SavingsAccount Classes Design an abstract class named BankAccount to hold the following data for… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *