-3
誰かがこのループの仕組みを説明できますか? if文を実行するタイミングとwhileループに戻るタイミングを理解するのが難しいです。これはどのようにループしているのですか?
// keep buying phones while you still have money
while (amount < bank_balance) {
// buy a new phone!
amount = amount + PHONE_PRICE;
// can we afford the accessory?
if (amount < SPENDING_THRESHOLD) {
amount = amount + ACCESSORY_PRICE;
}
}
また、ifでelseコンポーネントを使用しないと、なぜ動作しますか?