package temperatureconversion;
import java.util.Scanner;
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.println("Please enter Conversion type: Press C for Celsius to Fahrenheit or press F For Fahrenheit to Celsius.");
String Vctype = keyboard.next();
if (Vctype == "f" || Vctype == "F"){
System.out.println("Please enter fahrenheit");
double Vfahrenheit = keyboard.nextInt();
Vfahrenheit = (Vfahrenheit)*(9/5)+(32);
System.out.println(Vfahrenheit);
}
if (Vctype == "c" || Vctype == "C"){
System.out.println("Please enter celcius");
double Vcelcius = keyboard.nextInt();
Vcelcius = (Vcelcius - 32)*(5/9);
System.out.println(Vcelcius) ;
}
}
}
大家好,我想知道是否有人可以帮助我处理上述代码。基本上在netbeans的输出控制台中,程序似乎只是在我点击C或F后结束,但它应该要求输入一个数字,然后允许输入一个数字,然后计算并最终显示计算结果。它似乎没有执行 if 语句我哪里出错了?