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 prewritten class BankAccount as shown below Note: User enter the values
a Implement two constructors: name and assigned 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
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 benben.toString should return: Benson, $
If the client code were to call System.out.printlnbenben; 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 #
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
