java入门编程题

写一个将华氏温度转换成摄氏温度的程序,转换的公式是:
°F = (9/5)*°C + 32
其中C表示摄氏温度,F表示华氏温度。
程序的输入是一个整数,表示华氏温度。输出对应的摄氏温度,也是一个整数。
提示,为了把计算结果的浮点数转换成整数,需要使用下面的表达式:
(int)x;
其中x是要转换的那个浮点数。

第1个回答  2019-01-04
import java.util.Scanner;
public class Program {
    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        System.out.println("请输入华氏温度:");
        int F=s.nextInt();
        double Cd=(F-32)/9*5D;
        int C=(int)Cd;
        System.out.println("摄氏温度:");
        System.out.println(C);
    }
}

本回答被提问者采纳
第2个回答  2019-01-04
这都不会,趁早别学了
相似回答