第2关:温度转换

任务描述

从键盘输入一个摄氏温度,编写程序将摄氏温度转换为华氏温度,并输出。

任务分析

摄氏温度转换为华氏温度的数学公式为:f = c* 9/ 5.0 + 32,其中c表示摄氏温度,f表示华氏温度。这里涉及到数学计算和赋值,并且计算式涉及到浮点数和整数的乘积和求和,这在C#语言中为数据类型转换。

输入

输入一行数据,为摄氏温度c的值。

输出

f的值,即转换后的华氏温度。

编程要求

根据提示,在右侧编辑器补充代码,计算并输出华氏温度。

测试说明

我会对你编写的代码进行测试:

测试输入:10

预期输出:f=50

测试输入:78

预期输出:f=172.4

提示:

注意输入输出格式。

开始你的任务吧,祝你成功!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ch202
{
    class Program
    {
        static void Main(string[] args)
        {
			/******begin*******/
			double f, c;
            c = Convert.ToDouble(Console.ReadLine());
            f = c * 9 / 5.0 + 32;
            Console.WriteLine("f={0}", f);
			
			
			/*******end********/

        }
    }
}

  

posted @ 2020-03-12 19:39  青衫客36  阅读(758)  评论(0编辑  收藏  举报