如何编写将温度摄氏温度转换为华氏温度的C#控制台程序。使用for循环 [英] How do I write a C# console program that converts temperature celsius to fahrenheit. Using a for loop

查看:156
本文介绍了如何编写将温度摄氏温度转换为华氏温度的C#控制台程序。使用for循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天。

我是C#的新手。

我在教科书中找不到以下问题的解决方案:



编写一个C#控制台程序,将温度以摄氏度转换为度数

华氏度。显示-40摄氏度到+40摄氏度的所有值,步长为5美元的
。例如,你的输出应该显示-40,-35,-30,-25等等,上涨

到+40摄氏度。



对于以摄氏度显示的每个值,您的程序需要使用以下公式计算华氏度等效温度:

f =(9.0 / 5.0) * c + 32,其中'c'是以摄氏度为单位的温度,'f'是华氏温度的





该程序必须使用for循环。



我不知道如何开始。

请帮忙。



我尝试了什么:



我试过在google上寻找解决方案,但我还没找到一个使用for循环的程序。



请大家,非常感谢你的帮助。

Good day people.
I'm really new to C#.
I can't find the solution to the following question in my textbook:

Write a C# console program that converts temperature in degrees Celsius to degrees
Fahrenheit. Show all values from –40 degrees Celsius to +40 degrees Celsius in steps
of 5 degrees. For example, your output should show –40, –35, –30, –25 and so on, up
to +40 degrees Celsius.

For each value shown in degrees Celsius, your program is required to calculate the
equivalent temperature in degrees Fahrenheit using the following formula:
f = (9.0/5.0) * c + 32, where 'c' is the temperature in Celsius and 'f' is the
temperature in Fahrenheit.

The program must use a for loop.

I have no idea how to start.
Please help.

What I have tried:

I have tried looking on google for a solution but I haven't found a program that uses a for loop.

Please guys, your help is much appreciated.

推荐答案

for (int c = -40; c <= 40; c += 5)
{
    // Conversion code here...
}



for(C#Reference)| Microsoft Docs [ ^ ]


您是否尝试过查看附录?

所有优秀的教科书都包含答案。
Have you tried looking in the appendix?
All good textbooks have the answers included.


这篇关于如何编写将温度摄氏温度转换为华氏温度的C#控制台程序。使用for循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆