Question: Suppose that you are provided with a pre - written class BankAccount as shown below ( Note: User enter the values ) . a .

Suppose that you are provided with a pre-written class BankAccount as shown below (Note: User enter the values).
a. Implement two constructors: name and assigned 0 balance
Given name and balance
b. Implement getters (the headings are given)
c. Implement deposit method: Adds the amount to the balance if it is between 0-500.
d. Implement withdraw methods: Subtracts the amount from the balance if the user has enough money; if not, do not make any change and report unsuccessful attempt
e. Implement toString method: Add a toString method to the BankAccount class. Your method should return a string that contains the account's name and balance separated by a comma and space. For example, if an account object named benben has the name "Benson" and a balance of 17.25, benben.toString() should return: Benson, $17.25
If the client code were to call System.out.println(benben); , that text would be shown on the console.
f. OPTIONAL: Implement equalAmount method that returns true if two accounts have the same balance, false otherwise [Example: Equals method Slide #40]
g. Write a short client program that constructs and initializes an account, then prints it: BankAccountTest.java program that tests all your methods

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!