import java.util.Scanner; // This program provides a text based interface to the bank account class // Some possible improvements: // Allow the command to be in any case or partial // (for example allow entering Q or qu for query) // Add a loop so that we can do multiple operations public class BankAccountTester2 { public static void main( String[] args ) { Account b1 = new Account(5000); // We're rich! String command; // Prepare to read from the keyboard. java.util.Scanner s = new java.util.Scanner( System.in ); // The following lines are some test lines that we tried // nextLine inputs an entire line // System.out.print( "Enter a string: "); // command = s.nextLine(); // System.out.println( command); System.out.print( "Do you want to add, remove, or query: " ); command = s.next(); // Reads the next word typed at the keyboard. if (command.equals("add")) { System.out.print( "How much do you want to add: " ); command = s.next(); // Reads the next word typed at the keyboard. double amount = Double.parseDouble(command); b1.deposit(amount); System.out.println( "current bal is " + b1.getBalance()); } else if (command.equals("remove")) { System.out.print( "How much do you want to remove: " ); command = s.next(); // Reads the next word typed at the keyboard. double amount = Double.parseDouble(command); if (amount > b1.getBalance()) { System.out.println( "You dont have that much money!"); } else { b1.withdraw(amount); } System.out.println( "current bal is " + b1.getBalance()); } else if (command.equals("query")) { System.out.println( b1.getBalance() ); } else // Handle any other words { System.out.println( "Invalid command"); } System.out.println( "Bye!"); } // end of public static void main } // end of class BankAccountTester2