题解 | #温度转换#
温度转换
https://www.nowcoder.com/practice/ba83647087b7447783fa2384da6b3d44
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNext()) { // 注意 while 处理多个 case
// int f = in.nextInt(); // 输入的数字不一定都是int类型
double f = in.nextDouble();
if(f >= 1 & f <= 100000){
// double num = (5*((double)f-32))/9; // 要给f转类型,否则公式里的数字都是int类型,结果是int类型,导致结果不精确。
double num = (5*(f-32))/9;
System.out.printf("%.3f",num);
// System.out.print(String.format("%.3f",num));
}
}
}
}

