-3

因此,我想编写一个应用程序来读取以小时、分钟和秒为单位的时间值。然后以秒为单位打印相同的时间。(例如,1 小时 28 分 42 秒等于 5322 秒。)我使用 JCreator,当我尝试编译时,它告诉我在第 21 行有 2 个错误,即
System.out.println(“你答案等于 =" +time "秒"); 它告诉我的错误是 ')' 是预期的,并且是非法的表达开始。

 import java.util.Scanner;
    public class StackOverflow.swag // for teh lulz
    {
        public static void main (String [] args);
        {
            double time, hours, minutes, seconds;
            seconds = 0.0;
            minutes = minutes*3600;
            hours = hours*216000;
            time = seconds+minutes+hours;
            Scanner scan = new Scanner (System.in);

            System.out.println ("Enter number of hours");
            hours = scan.nextDouble();
            System.out.println ("Enter number of minutes");
            minutes = scan.nextDouble();
            System.out.println ("Enter number of seconds");
            seconds = scan.nextDouble();


            System.out.println ("Your answer equals =" +time+ "seconds");


        }
    }
4

1 回答 1

6

您缺少一个+betweentime"seconds"。改变

System.out.println ("Your answer equals =" +time "seconds");

System.out.println ("Your answer equals =" + time + "seconds");

main此外,您的方法签名后有一个不正确语法的分号。改变

public static void main (String [] args);

public static void main (String [] args)
于 2013-09-26T00:03:15.797 回答