Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design a SavingAccount class that stores a savings accounts annual interest rate

ID: 3563638 • Letter: D

Question

Design a SavingAccount class that stores a savings accounts annual interest rate and balance. The class constructor should accept the amout of the savings accounts starting balance. The class should also have methods for subtracting the amount of a withdrawal, adding the amount of a deposit and adding the amount of monthly interest to the balance. the monthly interest rate is the annual interest rate divided by twelce. to add the monthly interest to the balance, multiply the monthly interest rate by the balance, and add the result to the balance.

Test the class in a program that calculates the balance of a savings account at the end of a period of time. It should ask the user for the annual interest rate, the starting balance, and the number of months that have passed since the account was established. A loop should iterate once for every month, performing the following:

A- Ashe the user for the amount deposited into the account during the month. Use the class method to add this amount to the account balance.

B- Ash the user for the amount withdrawn from the account during the month. Use the class method to subtract this amount from the account balance.

C-Use the class method to calculate the monthly interest.

After the last iteration the program should display the ending balance, the total amount of deposits, the total amount of withdrawals, and the total interest earned.

THEN

Creat a text file named Deposits.txt the file should contain the following numbers ( one per line)

(100.00/124.00/78.92/37.55)

Creat another text file named Withdrawals.txt (one per line)

(29.88/110.00/27.52/50.00/12.90)

The numbers in the Deposits.txt file are the amounts of deposits the were made to a savings account during the month, and the numbers in the Withdrawals.txt file are the amounts of withdrawals the were made during the month. Write a program that creates an instance of the SavingsAccount class that you wrote. The starting balance for the object is 500.00. The program should read the values from the Deposits.txt file and use the objects method to add them to the account balance. The program should read the values from the Withdrawls.txt file and use the objects method to subtract them from the account balance. The program should call the class method to calculate the monthly interest, and display the ending balance and the total interest earned.

Explanation / Answer

BankAccount.java public class BankAccount { private static int nextAccountNumber = 10000; private static double currentInterestRate = 0.05; public static void setCurrentRate(double newRate) { currentInterestRate = newRate; } private int accountNumber; private double balance; private double rate; public Account(double initialBalance) { accountNumber = nextAccountNumber++; balance = initialBalance; rate = currentInterestRate; } public int getAccountNumber() { return accountNumber; } public double getBalance() { return balance; } public double getRate() { return rate; } public double getCurrentRate() { return currentInterestRate; } public void deposit(double amount) { balance += amount; } public boolean withdraw(double amount) { if (amount > balance) // refuse to let account be overdrawn return false; else { balance -= amount; return true; } } public void updateRate() { rate = currentInterestRate; } public void elapse(int numberOfDays) { for (int day = 1; day = amount+minAmount) { super.withdraw(amount); return true; } else return false; } private double minAmount; } private intnumberOfWithdrawals; public SavingsAccount () { balance = 0; numberOfWithdrawals = 0; } public voidwithdraw (intamount) { if (numberOfWithdrawals > 4) { throw newRuntimeException (