gpt4 book ai didi

java - 转换测量程序。如果声明说;预期的?

转载 作者:行者123 更新时间:2023-11-30 08:31:12 24 4
gpt4 key购买 nike

<分区>

请有人看一下我的代码。它不会编译,因为它说;此处预期 - }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");


}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com