package temperature.convert;
import java.util.Scanner;
public class Convert {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int flag,centigrade,fahrenheit;
double centigrade1,fahrenheit1;
System.out.println("摄氏温度和华氏温度转换:1——摄氏温度转换为华氏温度");
System.out.println(" 2——华氏温度转换为摄氏温度");
/*
* 下面代码段用于从键盘输入一个整数,用于进行温度转换
*/
System.out.println("请输入你的选择:");
Scanner input1=new Scanner(System.in);
flag=input1.nextInt();
if(flag==1)
{
System.out.println("请输入摄氏温度:");
Scanner input2=new Scanner(System.in);
centigrade=input2.nextInt();
fahrenheit1=9.0*centigrade/5.0+32;
System.out.printf("摄氏温度转换为华氏温度:% .1f ", fahrenheit1);
}else if(flag==2){
System.out.println("请输入华氏温度:");
Scanner input3=new Scanner(System.in);
fahrenheit=input3.nextInt();
centigrade1=5*(fahrenheit-32)/9.0;
System.out.printf("华氏温度转换为摄氏温度:% .1f ",centigrade1);
}else
{
System.out.println("输入错误,程序结束!");
}
}