import java.util.*; import java.io.*; import java.text.*; public abstract class MainProg { public static void main(String[] args) { Scanner reader = new Scanner(System.in); int num_accounts; int num_modifying; int mod_number; int view_number; int howmuch; int _tempbalance; boolean creating_accounts; String w_or_d = ""; String _tempname = ""; System.out.print("How many accounts do you want to add?"); num_accounts = reader.nextInt(); reader.nextLine(); if (num_accounts == 0) { creating_accounts = false; }else{ creating_accounts = true; } bankAccount[] accountArray = new bankAccount[num_accounts]; for(int f = 0; f < num_accounts; f++) { accountArray[f] = new bankAccount(); } if (creating_accounts) { for (int i = 0; i < num_accounts; i++){ accountArray[i].setName("test"); accountArray[i].setBalance(0); System.out.print("What is the person's name?" + " (person " + i + "): "); _tempname = reader.nextLine(); reader.nextLine(); accountArray[i].setName(_tempname); System.out.print("What is his/her's balance?: "); _tempbalance = reader.nextInt(); reader.nextLine(); accountArray[i].setBalance(_tempbalance); } } System.out.print("You want to change an account.(true/false): "); String _tempboolmod = reader.nextLine(); reader.nextLine(); if (_tempboolmod.compareTo("true")==0) { while (_tempboolmod.compareTo("true")==0) { System.out.print("What number?: "); mod_number = reader.nextInt(); reader.nextLine(); System.out.print("Withdraw or Deposit?: "); w_or_d = reader.nextLine(); reader.nextLine(); System.out.print("How much?: "); howmuch = reader.nextInt(); reader.nextLine(); if (w_or_d.compareTo("Withdraw")==0) { accountArray[mod_number].withdraw(howmuch); } if (w_or_d.compareTo("Deposit")==0) { if (howmuch > 0) { accountArray[mod_number].deposit(howmuch); }else{ System.out.println("You cannot deposit a negative amount."); } } System.out.println(accountArray[mod_number].getBalance()); System.out.print("Modify another?(true/false): "); _tempboolmod = reader.nextLine(); reader.nextLine(); if (_tempboolmod.compareTo("true")==0) { continue; }else{ break; } } } System.out.print("You want to view an account.(true/false): "); String _tempboolview = reader.nextLine(); // viewing_account = (boolean)_tempboolview; if (_tempboolview.compareTo("true")==0) { while (_tempboolview.compareTo("true")==0) { System.out.print("Which number?: "); view_number = reader.nextInt(); System.out.println(accountArray[view_number].getName()); System.out.println(accountArray[view_number].getBalance()); reader.nextLine(); System.out.print("View another?(true/false): "); _tempboolview = reader.nextLine(); // viewing_account = (boolean)_tempboolview; if (_tempboolview.compareTo("true")==0) { continue; }else{ break; } } } } }