2013-05-15 74 views
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!"); 

這只是我的代碼的一部分。不幸的是,命令提示符不斷告訴我有一個錯誤在Java錯誤:')'預計

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

它說,有一個')'的預期。我明白這意味着什麼,但我找不到括號丟失的地方......我很困惑。任何幫助將不勝感激!

+4

您錯過了'+'b etween「利潤是」和「$」 –

+0

在貨幣符號前,您已經有額外的報價。 –

+1

我建議你閱讀每一行,並問自己「能理解嗎?」。如果你總是這樣做,你會避免許多錯誤。 –

回答

4

你錯過了在基於邏輯

之間
"profit is " "$" 
      ^

一個+標誌,我覺得你其實並不意味着包括雙引號:

"profit is $" 
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));