第二章第一题(将摄氏温度转换为华氏温度)(Convert Celsius to Fahrenheit)

2.1(将摄氏温度转换为华氏温度)编写程序,从控制台读入double型的摄氏温度值,然后将其转换为华氏温度,并且显示结果。转换公式如下所示:

华氏温度 = (9 ÷ 5)× 摄氏温度 + 32
提示:在Java中,9/5的结果是1,但是9.0/5的结果是1.8。
下面是一个运行示例:
Enter a degree in Celsius:43.5
43.5 Celsius is 110.3 Fahrenheit

2.1(Convert Celsius to Fahrenheit) Write a program that reads a celsius in a double value from the console, converts it to fahrenheit, and displays the result. The formula for the conversion is as follows:

celsius = (9 ÷ 5) × fahrenheit + 32
Hint: In Java, the result of 9/5 is 1,but 9.0/5 is 1.8.
Here is a sample run:
Enter a degree in Celsius:43.5
43

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值