import java.io.*; class AccountMain5 { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); System.out.println("How much to start off with?"); int sum = Integer.parseInt(in.readLine()); AccountA acc1 = new AccountA(sum),acc2; System.out.println("How much of this to start your second account?"); while(true) { sum = Integer.parseInt(in.readLine()); acc2 = acc1.open(sum); if(acc2!=null) break; System.out.println("You don't have that much, try again"); } while(acc2==null); System.out.println("Deposit how much in your first account? "); sum = Integer.parseInt(in.readLine()); acc1.deposit(sum); System.out.println("Transfer how much to your second account? "); while(true) { sum = Integer.parseInt(in.readLine()); if(acc1.transfer(acc2,sum)) break; System.out.println("You don't have that much,try again"); } System.out.println("Withdraw how much from your second account?"); while(true) { sum = Integer.parseInt(in.readLine()); if(acc2.withdraw(sum)) break; System.out.println("You don't have that much, try again"); } System.out.println("Final balances:"); System.out.println(" First account: "+acc1.balance()); System.out.println(" Second account: "+acc2.balance()); } }