My understanding of the continue statement is that if it's used in a do...while loop, it should jump to the bottom of the loop and execute the next statment. So if I use a continue in the inner of two loops, and the outer loop's(do...while) end is the statement after the inner loop's end, the while of the do...while should evaluate it's condition. I'm not getting that to work. Here's my code. I'm probably missing something simple, but have been banging my head against the table with this problem for a while.
public class LoopInvestmentDialog {
static int termNum;
static char term;
static
String termString;
static Integer termInt;
static String principalCode = "x";
static double principal = 0;
static double newPrincipal = 0;
static double interest = 0;
static double balance = 0;
static boolean quit = false;
public static void main(String[] args) throws Exception {
do {
while (principalCode.charAt(0) != 'A' &&
principalCode.charAt(0) != 'B' &&
principalCode.charAt(0) != 'C' &&
principalCode != "quit") {
principalCode = JOptionPane.showInputDialog
("Please enter A) for $1,000 B) for $5,000 C) for $10,000 or quit) for quit");
quit = principalCode.equalsIgnoreCase("quit");
}
switch (principalCode.charAt(0)) {
case 'A':
principal = 1000.00;
break;
case 'B':
principal = 5000.00;
break;
case 'C':
principal = 10000.00;
break;
default:
break;
}
if (quit == true) {
continue;
/* shouldn't this jump it out to where the outer loop evaluates?
*/
}
System.out.print("Enter number of years 1-9: ");
term = (char) System.in.read();
System.in.read();
System.in.read();
String strVal = String.valueOf(term);
termNum = Integer.parseInt(strVal);
for (int counter = 1; counter <= termNum; ++counter) {
interest = principal * .08 * 100;
interest = Math.round(interest);
balance = principal * 1.08 * 100;
balance = Math.round(balance);
interest = interest / 100;
balance = balance / 100;
System.out.println("Interest for this year is $" + interest +
". This year's balance is $" + balance + ".");
principalCode = "x";
principal = balance;
}
System.out.println(quit);
} while (quit == false);
System.exit(0);
}
}
Please, please, please help me!
Aaron Parker