1 changed files with 32 additions and 32 deletions
@ -1,33 +1,33 @@ |
|||||
#借用键盘输入工具 |
#借用键盘输入工具 |
||||
import java.util.Scanner; |
import java.util.Scanner; |
||||
#代码放这里 |
#代码放这里 |
||||
public class Temperature{ |
public class Temperature{ |
||||
#从这里开始 |
#从这里开始 |
||||
public static void main(String[]args){ |
public static void main(String[]args){ |
||||
#创建输入工具 |
#创建输入工具 |
||||
Scanner sc=new Scanner(System.in); |
Scanner sc=new Scanner(System.in); |
||||
#print这些字 |
#print这些字 |
||||
System.out.println("1.华氏度转摄氏度"); |
System.out.println("1.华氏度转摄氏度"); |
||||
System.out.println("2.摄氏度转华氏度"); |
System.out.println("2.摄氏度转华氏度"); |
||||
System.out.println("请选择1/2"); |
System.out.println("请选择1/2"); |
||||
#新变量 |
#新变量 |
||||
int choice=sc.nextInt(); |
int choice=sc.nextInt(); |
||||
#读取输入之物 |
#读取输入之物 |
||||
if (choice==1){ |
if (choice==1){ |
||||
System.out.print("请输入温度:"); |
System.out.print("请输入温度:"); |
||||
#把输入的温度存到c |
#把输入的温度存到c |
||||
double c=sc.nextDouble(); |
double c=sc.nextDouble(); |
||||
#把算出来的存到f |
#把算出来的存到f |
||||
double f=c*9/5+32; |
double f=c*9/5+32; |
||||
#输出 |
#输出 |
||||
System.out.printf("%.2f",f); |
System.out.printf("%.2f",f); |
||||
}else if(choice==2){ |
}else if(choice==2){ |
||||
System.out.print("请输入温度:"); |
System.out.print("请输入温度:"); |
||||
double c=sc.nextDouble(); |
double c=sc.nextDouble(); |
||||
double f=(c-32)*5/9; |
double f=(c-32)*5/9; |
||||
System.out.printf("%.2f",f); |
System.out.printf("%.2f",f); |
||||
} |
} |
||||
#关闭程序 |
#关闭程序 |
||||
sc.close(); |
sc.close(); |
||||
} |
} |
||||
} |
} |
||||
Loading…
Reference in new issue