Question: The following task needs to be written in java using repl.it Create a new class called BankAccount.java and have it contain the following: ~Data Fields:

The following task needs to be written in java using repl.it

Create a new class called BankAccount.java and have it contain the following:

~Data Fields:

*The owner's name

*Balance (how much money is in the account)

~Constructor:

*A custom constructor that takes in the owner's name and balance

~Methods:

*A getter for name

*A getter for balance

*A deposit method to allow the owner to add additional funds

*A withdraw method to allow the user to take out money (if there is enough). Do not allow the user to withdraw more money than the current balance

*a toString() method to display the owner's name and account balance.

Part Two:

Write a driver that:

*Instantiates a new bank account

*Displays the initial name and balance

*Deposits funds

*Displays the name and new balance

*Withdraws funds (use a "legal" withdraw amount)

*Displays the name and new balance

Can someone please help me write the code for this. I really need help.

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!