Note that there are some explanatory texts on larger screens.

plurals
  1. PODo/while loop isn't executing properly
    primarykey
    data
    text
    <p>Im sure I am missing something simple but I cannot get my do while loop to execute properly. I want it to run through the first time and keep going until the user inputs q. It currently executes once and then loops back up to ask what account to access and then does nothing. Any help or pointing me in the right direction so I can fix it would be greatly appreciated. </p> <pre><code>public class Crawford_Driver { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); double input1; String accountChoice; String accountActivity; RegularAccount regAcct = new RegularAccount(0, .5); SavingsAccount savAcct = new SavingsAccount(0, .5); do{ System.out.println("What account would you like to access(regular or savings)?" ); accountChoice = keyboard.nextLine(); if(accountChoice.equalsIgnoreCase("regular")) System.out.println("What action do you wish to perform(deposit, withdraw or monthly process)? "); accountActivity = keyboard.nextLine(); if (accountActivity.equalsIgnoreCase("deposit")) { System.out.println("How much would you like to deposit?"); input1= keyboard.nextDouble(); regAcct.deposit(input1); System.out.println("Your balance is " + regAcct.getBalance() ); } else if (accountActivity.equalsIgnoreCase("withdraw")) { System.out.println("How much would you like to withdraw?"); input1= keyboard.nextDouble(); regAcct.withdraw(input1); System.out.println("Your balance is "+ regAcct.getBalance()); } else if (accountActivity.equalsIgnoreCase("monthly process")) { regAcct.monthlyProcess(); } else { if (accountChoice.equalsIgnoreCase("savings")) if (accountActivity.equalsIgnoreCase("deposit")) { System.out.println("How much would you like to deposit?"); input1= keyboard.nextDouble(); savAcct.deposit(input1); System.out.println("Your balance is " + savAcct.getBalance() ); } if (accountActivity.equalsIgnoreCase("withdraw")) System.out.println("How much would you like to withdraw?"); input1= keyboard.nextDouble(); savAcct.withdraw(input1); System.out.println("Your balance is "+ savAcct.getBalance()); } }while (!accountChoice.equalsIgnoreCase("Q")); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload