import java.io.*; public class Account { private int acctID; private double balance; public int getAcctID() { return acctID; } public double getBalance() { return balance; } public void setBalance(double newBalance) { balance=newBalance; } //added signature public Account(int _id, double _balance) { acctID=_id; balance=_balance; } // demonstrates function overloading for Account and the use of this to indicate member of the class and not // the formal parameters (which by the way has the same name as the member of the class). // --This is not recommended. public Account(int acctID) { this.acctID=acctID; balance=50.0; } public void deposit(double amount) { balance += amount; } public void withdraw(double amount) { balance -= amount; } public static void main(String args[]) throws IOException { BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in)); double w1, d2; //next line commented if using signature // Account a1= new Account(); Account a1= new Account(30,300.0); //next line commented if using signature //a1.setBalance(300.0); System.out.println("Balance of A1= $" + a1.getBalance()); Account a2= new Account(40); System.out.println("Balance of A2= $" + a2.getBalance()); System.out.print ("How much do you want to withdraw on A1 : $"); System.out.flush(); w1 = Double.parseDouble(stdin.readLine()); if (w1 <= a1.getBalance()) { a1.withdraw(w1); } else { System.out.print ("You only have : $" + a1.getBalance() + "in your account."); } System.out.print ("How much do you want to deposit on A2 : $"); System.out.flush(); d2 = Double.parseDouble(stdin.readLine()); a2.deposit(d2); System.out.println("New Balance of A1= $" + a1.getBalance()); System.out.println("New Balance of A2= $" + a2.getBalance()); } }