• 2
  • 82 Views
  • All levels

The Account class Create a class named Account, which has the following private properties: number: long balance: double Create a no-argument constructor that sets the number and balance to zero. Create a two-parameter constructor that takes an account number and balance. First, implement getters and setters: getNumber(), getBalance(), setBalance(double newBalance). There is no setNumber() -- once an account is created, its account number cannot change. Now implement these methods: void deposit(double amount) and void withdraw(double amount). For both these methods, if the amount is less than zero, the account balance remains untouched. For the withdraw() method, if the amount is greater than the balance, it remains untouched. Then, implement a toString() method that returns a string with the account number and balance, properly labeled.

Leave an answer

Our People Answers

0

(Based on todays review)

  • davideisenberg

    Answer:

    It looks as if you are in one of the COMSC 075 classes at the school where I teach -- this is one of your assignments.

    If you copy and paste someone’s answer, all you learn is how to copy and paste. That may get you through the course with a passing grade, but when you are on the job and get to your first code review and someone asks you why you decided to code something one way instead of another -- you’ll be stuck, because you will have no idea why your copy-and-pasted code works (or doesn’t).

    If you’re having trouble understanding how to approach the problem, contact one of the instructors so you can write the program yourself and understand what it’s doing. We’re available online for office hours via video conference. Just ask!

    Explanation: