因此,我想编写一个应用程序来读取以小时、分钟和秒为单位的时间值。然后以秒为单位打印相同的时间。(例如,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");
}
}