java eclipse编程摄氏温度 华氏温度转换

import java.util.Scanner;public class homework4{ public static void main(String[] args) { Scanner in=new Scanner(System.in); double f, c; f=in.nextDouble(); /*------------------*/ c=(5f/9f)*(f-32); System.out.println("The temprature is "+c); }}此为全部程序老师要求检验是输入数据17.2 输出-8.2222223(一共几个2不记得了 反正是3结尾)可是我输出的是-8.22222261428833 如何解决啊求解
2026年09月22日 19:29
有1个网友回答
网友(1):

Try this:

import java.util.Scanner;

public class homework4 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double f, c;
f = in.nextDouble();
/*------------------*/
c = (5f / 9f) * (f - 32);
System.out.printf("The temprature is %f", c);
}
}