Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Bank Account (repost last answer was a spam bot) In this project you will be writing your own bank account program in Account.java. The main

Bank Account (repost last answer was a spam bot)

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

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

More Books

Students also viewed these Databases questions

Question

Evaluate 3x - x for x = -2 Answer:

Answered: 1 week ago

Question

What is group replacement? Explain with an example. (2-3 lines)

Answered: 1 week ago

Question

3. What strategies might you use?

Answered: 1 week ago

Question

3. Write a policy statement to address these issues.

Answered: 1 week ago