Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use Java Bank Account Class a) Use the UML diagram in the file BankAccount.pdf attached below to implement a BankAccount class that stores a bank

Use Java

Bank Account Class

a) Use the UML diagram in the file BankAccount.pdf attached below to implement a BankAccount class that stores a bank accounts annual interest rate and balance (money in the bank account). UML Diagram of the Bank Account Class (name of the class) BankAccount (fields and their data types, private or public) - balance : double - interestRate : double (methods; their return types, their parameters, private or public) -BankAccount (startBalance : double, interest : double) -getBalance () : double -setBalane (newBalance : double) : void -getInterestRate () : double -setInterestRate (newInterest : double) : void -withdraw (amount : double) : void -deposit (amount : double) :void -addMonthlyInterest() : void (// add monthly interest amount to the balance)

The class constructor should accept the amount of the savings accounts starting balance and the annual interest rate. The class should also have

  • accessor and mutator methods for the balance, and for the interest rate fields.
  • a method for subtracting the amount of a withdrawal,
  • a method for adding the amount of a deposit,
  • a method for 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.

b) Write a test program that creates one bank account. The starting balance at the beginning of February is $500. The annual interest rate is 3% (0.03).

  1. The program reads each deposit made in February from the Deposits.txt file: 100.00 124.00 78.92 37.55 and uses the appropriate instance method to add it to the account balance.
  2. The program reads each withdrawal made in February from the Withdrawals.txt file: 29.88 110.00 27.52 50.00 12.90 and uses the appropriate instance method to subtract it from the account balance.
  3. The program calls the instance method to add the monthly interest.
  4. The program displays the balance at the end of February.

To better test your program also display the starting balance, and the balance after each deposit and after each withdrawal.

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

Next Generation Databases NoSQLand Big Data

Authors: Guy Harrison

1st Edition

1484213300, 978-1484213308

More Books

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago