You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
937 B
937 B
#借用键盘输入工具 import java.util.Scanner; #代码放这里 public class Temperature{ #从这里开始 public static void main(String[]args){ #创建输入工具 Scanner sc=new Scanner(System.in); #print这些字 System.out.println("1.华氏度转摄氏度"); System.out.println("2.摄氏度转华氏度"); System.out.println("请选择1/2"); #新变量 int choice=sc.nextInt(); #读取输入之物 if (choice==1){ System.out.print("请输入温度:"); #把输入的温度存到c double c=sc.nextDouble(); #把算出来的存到f 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(); } }