import java.util.*; public class Account { private double balance; private double[] previousBalances = new double[20]; private int numTransactions = 0; private String name; public static void main( String[] args ) { Scanner s = new Scanner( System.in ); int choice; Account account = new Account( "Dave", 50.00 ); do { System.out.println( "1. View Balance" ); System.out.println( "2. Deposit" ); System.out.println( "3. Withdraw" ); System.out.println( "4. Write Check" ); System.out.println( "5. View Previous Balanaces" ); System.out.println( "6. Exit System" ); System.out.println(); System.out.print( "Enter Choice:" ); choice = s.nextInt(); switch( choice ) { case 1: { System.out.println( "\nYour balance is: " + account.getBalance() + "\n" ); break; } case 2: { System.out.print( "\nHow much would you like to deposit? " ); double amount = s.nextDouble(); account.deposit( amount ); System.out.println( "Your new balance is: " + account.getBalance() + "\n" ); break; } case 3: { System.out.print( "\nHow much would you like to withdraw? " ); double amount = s.nextDouble(); account.withdraw( amount ); System.out.println( "Your new balance is: " + account.getBalance() + "\n" ); break; } case 4: { System.out.print( "\nHow much would you like to write a check for? " ); double amount = s.nextDouble(); account.writeCheck( amount ); System.out.println( "Your new balance is: " + account.getBalance() + "\n" ); break; } case 5: { double[] prevBal = account.getPreviousBalances(); System.out.print( "\nYour previous balances are:" ); for( double val : prevBal ) System.out.print( val + ", " ); System.out.println("\n"); break; } } } while ( choice != 6 ); } public Account( String name, double initialDeposit ) { this.balance = initialDeposit; this.name = name; } public double getBalance() { return balance; } public void deposit( double amount ) { previousBalances[numTransactions++] = balance; balance += amount; } public void withdraw( double amount ) { if ( balance - amount < 0.0 ) amount += 25; previousBalances[numTransactions++] = balance; balance -= amount; } public void writeCheck( double amount ) { withdraw( amount + 0.25 ); } public double[] getPreviousBalances() { double[] prevBal = new double[numTransactions]; System.arraycopy( previousBalances, 0, prevBal, 0, numTransactions ); return prevBal; } }