import java.util.*;
public class e2a {
public static void main(String[] args) {
String scf;
String sCF = "CF";
String sFC = "FC";
int iTemp;
int iConvTemp;
Scanner sin = new Scanner(System.in);
System.out.println("Please indicate what conversion you would like to make. Enter CF for Centigrade to Fahrenheit. Enter FC for Fahrenheit to Centigrade.");
scf = sin.next();
System.out.println("Please enter the temperature you would like to convert.");
iTemp = sin.nextInt();
if((scf).equals("CF"))
{ iConvTemp = (((iTemp*9)/5)+32);
System.out.println(iTemp + " in Fahrenheit is : " + iConvTemp);
}
else if((scf).equals("FC"))
{ iConvTemp = (((iTemp-32)*5)/9);
System.out.println(iTemp + " in Centigrade is : " + iConvTemp);
}
}
}
目标是让用户输入他们想要转换的方向和数字,然后使用if语句输出正确的值
答案 0 :(得分:0)
嘿所以我发现它是我的电脑,我在不同的电脑上运行它并且运行得很好。非常感谢你。我不得不重新启动我的编译器,让它再次运行。