转换公式: c= 5 / 9 (F – 32),使用Scanner需要导入包
代码:
public static void main(String[] args) {
System.out.println("请输入华氏温度:");
Scanner sc = new Scanner(System.in);
double f = sc.nextDouble();
int c = (int)(5.0 / 9 * (f - 32));
System.out.println("对应摄氏温度:" + c);
}