ユーザー入力が であるかどうかを示すコードが必要ですdouble
。の場合double
は変数に格納する必要がありdegreeCelsius
、そうでない場合はプログラムを終了する必要があります。全体として、プログラムはいくつかのdouble
値を取り、それらを摂氏として使用し、華氏に変換します。これは私がこれまでに持っているものです:
import java.util.*;
public class Lab4b
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
double degreeCelsius = 0.0;
double degreeFahrenheit = 0.0;
System.out.println("Celcius | Fahrenheit");
while(scan.next() != null)
{
//this is where I need the code. If you see any other errors, feel free to correct me
//if (degreeCelsius = Double)
{
degreeCelsius = scan.nextDouble();
}
else
{
System.exit(0);
}
degreeFahrenheit = degreeCelsius * (9.0/5.0) + 32.0;
}
}
}