Question
Bank Account In this project you will be writing your own bank account program in Account.java. The main method is provided to you in Main.java.
Bank Account
In this project you will be writing your own bank account program in Account.java. The main method is provided to you in Main.java. You do not need to update it.
That being said, you should comment out parts of the main method so that you can incrementally test your code in Account.java. It is not a good idea to write everything and then test it.
To Do
Within the Account.java file:
Data members (data fields)
- The class should have two instance variables called name and balance.
Constructors
- Write a default constructor.
- Write a constructor that takes all instance variables as parameters.
Instance methods (accessors and mutators)
- Write an accessor method to get the current balance value called getBalance().
- Write an accessor method to get the current name value called getName().
- Write a mutator method to set the current balance value called setBalance().
- Write a mutator method to set the current name value called setName().
- Write a mutator method to add deposits to the current balance value called deposit().
- Write a mutator method to subtract withdrawals from the current balance value called withdrawal().
- The method should check if there are sufficient funds to cover the withdrawal. If so, it should change the balance accordingly. If not it should print out Insufficient Funds.
- Write an instance method to return the state of the object as a String called toString(). This should return the name of the account and the balance (formatted properly as money).
Are you finished?
Run the Main file. If everything is correct, your output should match what is below.
Additionally, run the unit test and it will check the same thing.
Name: Y. P. Freely
Balance: $300.00
Name: Whatever R Us
Balance: $4,000.00
Name: Y. P. Freely
Balance: $249.75
Name: Whatever R Us
Balance: $3,649.75
Name: Y. P. Freely
Balance: $99.75
Name: Whatever R Us
Balance: $3,629.80
Name: Y. P. Freely
Balance: $187.09
Name: Whatever R Us
Balance: $3,679.80
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started