请有人看看我的代码。它不会编译,因为它说;在这里预期 - } elseif(convert == 2){。
我不明白为什么,我对此很陌生。 问候。
//用户选择要转换的测量单位,输入数字并显示转换。
class Convertweight
{
public static void main (String [] args)
{
Scanner input = new Scanner(System.in);
//Declare variables
double feet=0.0, temp=0.0, weight=0.0, metres=0.0, f=0.0, stone=0.0, convert=0.0;
//choices of measurment to convert
System.out.println("Please choose and enter either 1,2 or 3 from the measurements below.");
System.out.println("1. Feet to metres");
System.out.println("2. C temp to F temp");
System.out.println("3. KG to stone");
convert=input.nextDouble();
//convert measurment if option 1 is chosen.
if (convert == 1) {
System.out.println("Enter measurement");
feet=input.nextDouble();
metres=feet/3.28;
System.out.println(metres + "m");
//convert temperature if option 2 is chosen.
} elseif (convert == 2){
System.out.println("Enter temperature in celsius");
temp=input.nextDouble();
F=C*1.8+32;
System.out.println(F + "f");
//convert weight if option 3 is chosen.
} elseif (convert == 3){
System.out.println("Enter weight in KG");
weight=input.nextDouble();
stone=weight/6.35029318;
System.out.println(stone+"st");
}