输入一个华氏温度, 要求输出摄氏温度. 公式为c= (F-32) * 5 / 9. 如: 输入F=100, 输出37.7778.

思路:

输入一个华氏温度,根据公式转化成摄氏温度即可

代码:

public class Demo1 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.println("请华氏温度:");
		int huashi  = sc.nextInt();
		float c= (float)(huashi-32)*5/9;
		System.out.println(""+c);
	}
}

运行结果:

发布了28 篇原创文章 · 获赞 5 · 访问量 5802

猜你喜欢

转载自blog.csdn.net/weixin_41879980/article/details/95854781