试题 算法提高 温度转换

问题描述
  编写一个程序,输入一个摄氏温度,输出相应的华氏温度。在输出时,保留小数点后面两位。
  输入格式:输入只有一个整数,即摄氏温度。
  输出格式:输出只有一实数,即相应的华氏温度。
  输入输出样例
样例输入
35
样例输出
95.00
资源限制
时间限制:1.0s 内存限制:512.0MB

转化公式:C(摄氏度)=(F(华氏度)-32)÷1.8来转换。

代码块

import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		double c = sc.nextInt();
		double f = c*1.8 + 32;
		System.out.println(String.format("%.2f",f));
	}
}

在这里插入图片描述

发布了86 篇原创文章 · 获赞 3 · 访问量 1386

猜你喜欢

转载自blog.csdn.net/wnamej/article/details/105456840
今日推荐