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; //boolean modifying_account; //boolean viewing_account; String w_or_d = ""; String _tempname = ""; System.out.println("How many accounts do you want to add?"); num_accounts = reader.nextInt(); if (num_accounts == 0) { creating_accounts = false; }else{ creating_accounts = true; } bankAccount[] accountArray = new bankAccount[num_accounts]; if (creating_accounts) { for (int i = 0; i < num_accounts; i++){ accountArray[i].setName("test"); accountArray[i].setBalance(0); System.out.println("What is the person's name?" + " (person " + i + ")"); _tempname = reader.nextLine(); accountArray[i].setName(_tempname); System.out.println("What is his/her's balance?"); _tempbalance = reader.nextInt(); accountArray[i].setBalance(_tempbalance); } } System.out.println("You want to change an account.(true/false)"); String _tempboolmod = reader.nextLine(); reader.nextLine(); // modifying_account = (boolean)_tempboolmod; if (_tempboolmod.compareTo("true")==0) { while (_tempboolmod.compareTo("true")==0) { System.out.println("What number?"); mod_number = reader.nextInt(); System.out.println("Withdraw or Deposit?"); w_or_d = reader.nextLine(); System.out.println("How much?"); howmuch = reader.nextInt(); if (w_or_d.compareTo("Withdraw")==0) { accountArray[mod_number].withdraw(howmuch); } /*I would have put an else here instead of another if, but in a realistic setting, the person could hack the program by putting in somthing other than withdraw or deposit, if it had the else statement(and a validation thing or password was before that), and a deposit would be made. This also lets you have typos, and a deposit won't be made. */ if (w_or_d.compareTo("Depoisit")==0) { accountArray[mod_number].deposit(howmuch); } System.out.println(accountArray[mod_number].getBalance()); System.out.println("Modify another?(true/false)"); _tempboolmod = reader.nextLine(); // modifying_account = (boolean)_tempboolmod; if (_tempboolmod.compareTo("true")==0) { continue; }else{ break; } } } System.out.println("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.println("Which number?"); view_number = reader.nextInt(); System.out.println(accountArray[view_number].getName()); System.out.println(accountArray[view_number].getBalance()); System.out.println("View another?(true/false)"); _tempboolview = reader.nextLine(); // viewing_account = (boolean)_tempboolview; if (_tempboolview.compareTo("true")==0) { continue; }else{ break; } } } } }