Java华氏转摄氏

mac2022-06-30  57

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

 

转载于:https://www.cnblogs.com/zhaocundang/p/7523149.html

相关资源:java实验2.2(摄氏温度和华氏温度的转换)
最新回复(0)