Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN JAVA! Full javadocs is required! 1. (SavingsAccount.java, DepositsAndWithdrawals.java) Complete Programming Challenge #13 at the end of Chapter 6 in the textbook. This requires you

IN JAVA! Full javadocs is required!

1. (SavingsAccount.java, DepositsAndWithdrawals.java) Complete Programming Challenge #13 at the end of Chapter 6 in the textbook. This requires you to complete Programming Challenge #12. Submit your SavingsAccount class as well as a class with the main method. Implement your SavingsAccount class according to the UML diagram:

Savings Account

-balance : double -interestRate : double -lastInterest : double

+SavingsAccount(double,double) +withdraw(double) : void +deposit(double) : void +addInterest(void) : void +getBalance(void) : double +getInterestRate(void) : double +getLastInterest(void): double

Clarifications:

If there is a discrepancy between my UML and the book description, use my UML. For instance, I have only oneconstructor that takes the opening balance and interest rate. Thats the only constructor.

The instance variable lastInterest represents the amount of interest earned in the last month. Your program represents one month of activity. Process all deposits, then all withdrawals, then add interest based on resulting balance.

You need to complete Problem #12 to write the the SavingsAccount class. Be sure to test it, but you do not need to submit this testing class. You will submit the class (DepositsAndWithdrawals) that contains the main() method that solves #13.

A sample run of #13

Enter the savings account's annual interest rate: 2.5Starting Balance: $500.00 Deposit: $100.00, balance = $600.00 Deposit: $124.00, balance = $724.00

Deposit: $78.92, balance = $802.92 Deposit: $37.55, balance = $840.47 Withdraw: $29.88, balance = $810.59 Withdraw: $110.00, balance = $700.59 Withdraw: $27.52, balance = $673.07 Withdraw: $50.00, balance = $623.07 Withdraw: $12.90, balance = $610.17 Interest earned: $1.27 
Ending balance: $611.44 

12. SavingsAccount Class

Design a SavingsAccount class that stores a savings accounts annual interest rate and balance. The class constructor should accept the amount 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 twelve. 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 then iterate once for every month, performing the following:

  1. Ask the user for the amount deposited into the account during the month. Use the class method to add this amount to the account balance.

  2. Ask the user for the amount withdrawn from the account during the month. Use the class method to subtract this amount from the account balance.

  3. 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.

13. Deposit and Withdrawal Files

Use Notepad or another text editor to create a text file named Deposits.txt. The file should contain the following numbers, one per line:

100.00 124.00 78.92 37.55

Next, create a text file named Withdrawals.txt. The file should contain the following numbers, 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 that were made to a savings account during the month, and the numbers in the Withdrawals.txt file are the amounts of withdrawals that were made during the month. Write a program that creates an instance of the SavingsAccount class that you wrote in Programming Challenge 12. 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 Withdrawals.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 then display the ending balance and the total interest earned.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Main Memory Database Systems

Authors: Frans Faerber, Alfons Kemper, Per-Åke Alfons

1st Edition

1680833243, 978-1680833249

Students also viewed these Databases questions

Question

Describe Balor method and give the chemical reaction.

Answered: 1 week ago

Question

How to prepare washing soda from common salt?

Answered: 1 week ago

Question

1. Who is responsible for resolving this dilemma?

Answered: 1 week ago