package test; import java.util.Scanner; public class temperature { public static void main(String[] args) { double input_hs; double res; System.out.println("请输入华氏数值:"); Scanner input = new Scanner(System.in); input_hs=input.nextDouble(); change c=new change(); res=c.compute(input_hs); System.out.print("摄氏度是:"+res); } } class change{ double compute(double hs){ double ss=0.0; ss=(5.0/9)*(hs-32); return ss; } } 结果 请输入华氏数值: 100 摄氏度是:37.77777777777778