現在、while ループ内の行は、「10 ドルの手数料が請求されます」と「アカウントを閉鎖しますか?」です。
「10 ドルの手数料が請求されます」のように別の行に表示されます。
「指示はよろしいですか?」
両方のステートメントが 1 行に出力されるようにコードの書式を変更するにはどうすればよいですか。プログラムは同じように動作するはずです。
「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.");
}
}