class Account { private double balance; private String password; public Account(double initBalance, String pw) { balance = initBalance; password = pw; } public Account(String pw) { balance = 0; password = pw; } public double getBalance(String pw) { if (!password.equals(pw)) { System.err.println("Unauthorized!"); System.exit(1); } return balance; } public void withdraw(double amt, String pw) { if (!password.equals(pw)) { System.err.println("Unauthorized!"); System.exit(1); // end program } if (amt <= 0) { System.err.println("Amount must be positive"); return; // end method } if (balance < amt) { System.err.println("Insufficient funds"); return; // end method } balance = balance - amt; } public void deposit(double amt, String pw) { if (!password.equals(pw)) { System.err.println("Unauthorized!"); System.exit(1); // end program } if (amt <= 0) { System.err.println("Amount must be positive"); return; // end method } balance = balance + amt; } } public class TestAccount { public static void main(String[] args) { Account checking = new Account(100, "boat"); checking.withdraw(20, "boat"); System.out.println("balance = $" + checking.getBalance("boat")); checking.withdraw(200, "boat"); System.out.println("balance = $" + checking.getBalance("boat")); checking.withdraw(-20, "boat"); System.out.println("balance = $" + checking.getBalance("boat")); checking.withdraw(20, "boot"); System.out.println("balance = $" + checking.getBalance("boat")); } }