【发布时间】:2026-02-18 10:20:04
【问题描述】:
我正在做一个项目,您可以在其中输入桑拿的温度,如果您输入低温,它会告诉您提高温度,直到温度足够高,但我需要它不断要求更高的温度,直到您获得足够高的温度而无需重新启动程序,因此我需要能够更改循环中的温度,然后写出循环外的温度。
static void Main(string[] args)
{
Console.WriteLine("Enter temperature");
String tempInput = Console.ReadLine();
Int32 tempF = Convert.ToInt32(tempInput);
Int32 tempC = (tempF - 32) * 5 / 9;
Int32 tempCInDoLoop = 0;
Console.WriteLine("Temperature is to low, enter a higher temperature");
if (tempC < 73 && tempCInDoLoop < 73)
{
Console.WriteLine("Enter higher temperature");
String tempInputInDoLoop = Console.ReadLine();
Int32 tempFInDoLoop = Convert.ToInt32(tempInputInDoLoop);
Int32 tempCInDoLoop = (tempFInDoLoop - 32) * 5 / 9;
}
//Console.WriteLine(tempFInDoLoop);
}
【问题讨论】:
-
这里没有循环,可能是你的问题
-
“我需要能够改变循环中的温度”...好吧,那么是什么阻止你创建循环呢?目前还不清楚问题是什么。你试过什么?出了什么问题?
标签: c#