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 ステートメントを実行していないようです どこが間違っているのでしょうか?