Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.lang.*;
- public abstract class BankAccount {
- private double balance, balance2, balance3, deposit, withdraw;
- public BankAccount() {
- balance = 0;
- }
- public BankAccount(double y) {
- balance = y;
- }
- public void setBalance(double x) {
- balance = x;
- }
- public double getBalance() {
- return balance;
- }
- public void deposit(double x) {
- balance = balance + x;
- }
- public void withdraw(double y) {
- if ((balance - y) < 0) {
- throw new RuntimeException("You will overdraw your account");
- }
- else {
- balance = balance - y;
- }
- }
- public String toString() {
- String output;
- output = "The account has a balance of: $" + this.getBalance();
- return output;
- }
- public abstract double monthlyBalance();
- public abstract String toString();
- }
Add Comment
Please, Sign In to add comment