我的代码多次输出相同的字符串。例如,输入 40 会导致“不!您的答案太高。请重试。” 两次,并且显示两次“您的答案太低”。
while (numberguess != 40.5)
{
numberguess = Console.Read();
if (numberguess < 40.5)
{
Console.WriteLine("Nope! Your answer is too low. Try again.");
}
else if (numberguess > 40.5)
{
Console.WriteLine("Nope! Your answer is too high. Try again.");
}
else if (numberguess == 40.5)
{
Console.WriteLine("Correct! Wow, I didn't really think you would figure it out!");
break;
}
}
我希望在输入数字时只显示一个字符串,并且我希望它能够对应于它是低于还是高于特定数字。
慕标5832272
萧十郎
相关分类