0
System.out.println("Enter a department name:");

String firstDepartment = bufRead.readLine();

System.out.println("Enter number of employees:");

val1 = Double.parseDouble(bufRead.readLine());

System.out.println("Enter cost per employee:");

val2 = Double.parseDouble(bufRead.readLine());

System.out.println("Enter sales:");

val3 = Double.parseDouble(bufRead.readLine());

System.out.println("Hello, Donaldio! Your " + firstDepartment + "profit is " "$" + (val3 - val1 * val2));

String pleaseContinue = bufRead.readLine();

System.out.println("Please press enter!");

这只是我的代码的一部分。不幸的是,命令提示符一直告诉我有一个错误

System.out.println("Hello, Donaldio! Your " + firstDepartment + "profit is " "$" + (val3 - val1 * val2));

它说有一个')'预期。我明白这意味着什么,但我找不到括号丢失的地方......我很困惑。任何帮助将不胜感激!

4

2 回答 2

4

您错过了+中间的登录

"profit is " "$"
            ^

根据逻辑,我认为您实际上并不是要包含那些双引号:

"profit is $"
于 2013-05-15T01:55:17.543 回答
2
System.out.println("Hello, Donaldio! Your " + firstDepartment + "profit is " "$" + (val3 - val1 * val2));

应该

System.out.println("Hello, Donaldio! Your " + firstDepartment + "profit is $" + (val3 - val1 * val2));
于 2013-05-15T01:55:26.427 回答