现在,while 循环中的行“您将被收取 10 美元的费用”和“您想关闭您的帐户吗?” 出现在单独的行中,例如...
“您将被收取 10 美元的费用。”
“需要指示吗?”
如何更改代码的格式,以便将两条语句打印在一行上。该程序应该仍然可以正常工作。答案应显示为
“您将被收取 10 美元的费用。您要关闭您的帐户吗?”
import acm.program.*;
public class BankAccount extends ConsoleProgram {
public void run() {
int bankRoll = 50;
while(bankRoll > 0) {
println("Currently your balance is " + bankRoll + " . ");
println("You will be charged a fee of 10 dollars.");
String closeAct = readLine("Would you like to close your account?");
if(closeAct.equals("yes")) {
break;
}
bankroll -= 10;
} /* end of while loop */
println("your account is now closed.");
}
}