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.
21 lines
704 B
21 lines
704 B
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();
|
|
}
|
|
}
|