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));
它表示需要一个“)”。我明白它的意思,但我找不到括号缺少的地方......我很困惑。任何帮助将不胜感激!
最佳答案
您错过了 +
符号
"profit is " "$"
^
根据逻辑,我认为您实际上并不是要包含这些双引号:
"profit is $"
关于Java错误: ')' expected,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16555530/