1 changed files with 21 additions and 0 deletions
@ -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 |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue