- #1
Arnoldjavs3
- 191
- 3
Homework Statement
[/B]
So my professor has given this as a lab activity. He has not given any sample outputs, other than these simple instructions. I don't actually understand to what extent I'm to perform this activity to.
- Write a class BankAccount that contains a double field balance, and the following methods: (a) double getBalance() that returns the current balance of that account (b) void deposit(double amount) that increases the balance by the given amount (c) void withdraw(double amount) that decreases the balance by the given amount. Last, write a proper toString method in your class.
Homework Equations
"similar example code" http://pastebin.com/1n6bhHtT
The Attempt at a Solution
Java:
public class BankAccount {
double balance;
public double getBalance() {
return balance;
}
public void deposit(double amount) {
balance += amount;
}
public void withdraw(double amount) {
balance -= amount;
}
public void toString() {
return balance + "$";
}
}
Last edited: