-4
我想要做的是將提款額限制在20美元以內,最高爲500美元。我知道我在這裏錯過了一些簡單的元素來做到這一點。我的代碼工作,直到我試圖做的20簡單For循環和if語句
double AccountBalance = 1500;
double WithdrawalAmount;
WithdrawalAmount = double.Parse(textInput.Text);
Double MaxWithdrawalAmount = 0;
for (MaxWithdrawalAmount = 0; MaxWithdrawalAmount <= 500; MaxWithdrawalAmount += 20)
{
if (WithdrawalAmount == MaxWithdrawalAmount)
{
double Total = (AccountBalance - WithdrawalAmount);
textTotal.Text = ("Total amount" + Convert.ToString(Total));
}
else
{
textError.Text = ("Only Increments of $20 allowed for withdraw up to $100");
textTotal.Text = ("" + AccountBalance);
}
}
究竟是什麼「不工作」?你可以提供一些示例輸出嗎? –
現在沒有工作? –
您似乎在for語句後缺少範圍括號。 –