该计划的目的是创建一个帐户程序,以指示每月2个问题。我记录了月份输入,现在的问题是..如何编写循环以反复询问这两个问题并在输入数字设置为月份时停止?
System.out.println("How many months had passed since the account was established?");
months = keyboard.nextInt();
//count should be months, not sure how to word it from the month input.
int count=0; for(count=0;count<13;count++)
{ System.out.println("How much did you deposit this month?");
System.out.println("How much did you withdraw this month?");
System.out.println("Your monthly interest is");
}
答案 0 :(得分:0)
我认为这就是你要找的东西,但很难说......
for(int count=0;count<months;count++) {
System.out.println("How much did you deposit this month?");
deposit = scanner.nextDouble();
System.out.println("How much did you withdraw this month?");
withdraw = scanner.nextDouble();
//Do the math here....
System.out.println("Your monthly interest is" + result);
}