diff --git a/TemperatureConverter.java b/TemperatureConverter.java new file mode 100644 index 0000000..8626c7f --- /dev/null +++ b/TemperatureConverter.java @@ -0,0 +1,21 @@ +import java.util.Scanner; +public class Temperature{ + public static void main(String[]args){ + System.out.println("1.华氏度转摄氏度"); + System.out.println("2.摄氏度转华氏度"); + System.out.println("请选择1/2"); + int chioce=sc.nextlnt(); + if (choice==1){ + System.out.print("请输入温度:") + double c=sc.nextDouble(); + double f=c*9/5+32; + System.out.printf("%.2f",f) + }else if(choice==2){ + System.out.print("请输入温度:") + double c=sc.nextDouble(); + double f=(c-32)*5/9; + System.out.printf("%.2f",f) + } + sc.close + } +} \ No newline at end of file