我正在編寫一個程序,以英寸和英尺的高度查詢用戶的理想體重。到目前爲止,除了最後的聲明外,一切看起來都很好,在這個聲明中,我向用戶返回了男性和女性的平均體重,並告訴他們體重在15%之間的範圍。下面是給了我一個問題的代碼:在println語句中使用字符串和變量
System.out.println("For a male, the height " + foot "' " +
inches + "/""" + " and it's ideal weight is " +
mWeight + "lbs. Anything between " + minMaleLb +
"lbs and " + maxMaleLb + "lbs is okay.");
System.out.println("For a female, the height " + foot "' " +
inches + "/""" + " and it's ideal weight is " +
fWeight + "lbs. Anything between " + minFeMaleLb +
"lbs and " + maxFeMaleLb + "lbs is okay.");
這裏是我收到編譯時錯誤:
File: C:\Users\###\Java\IdealWeight.java [line: 26]
Error: C:\Users\###\Java\IdealWeight.java:26: ')' expected
File: C:\Users\###\Java\IdealWeight.java [line: 27]
Error: C:\Users\###\Java\IdealWeight.java:27: not a statement
File: C:\Users\###\Java\IdealWeight.java [line: 27]
Error: C:\Users\###\Java\IdealWeight.java:27: ';' expected
File: C:\Users\###\Java\IdealWeight.java [line: 29]
Error: C:\Users\###\Java\IdealWeight.java:29: not a statement
File: C:\Users\###\Java\IdealWeight.java [line: 29]
Error: C:\Users\###\Java\IdealWeight.java:29: ';' expected
File: C:\Users\###\Java\IdealWeight.java [line: 31]
Error: C:\Users\###\Java\IdealWeight.java:31: ')' expected
File: C:\Users\###\Java\IdealWeight.java [line: 32]
Error: C:\Users\###\Java\IdealWeight.java:32: not a statement
File: C:\Users\###\Java\IdealWeight.java [line: 32]
Error: C:\Users\###\Java\IdealWeight.java:32: ';' expected
File: C:\Users\###\Java\IdealWeight.java [line: 34]
Error: C:\Users\###\Java\IdealWeight.java:34: not a statement
File: C:\Users\###\Java\IdealWeight.java [line: 34]
Error: C:\Users\###\Java\IdealWeight.java:34: ';' expected
File: C:\Users\###\Java\Weight.java [line: 30]
Error: C:\Users\###\Java\Weight.java:30: reached end of file while parsing
File: C:\Users\###\Java\Weight.java [line: 34]
Error: C:\Users\###\Java\Weight.java:34: reached end of file while parsing
可有人請向我解釋什麼是錯的代碼,以及如何將我去解決這個問題?
您還缺少一些+。例如:'foot''「'而不是'foot +''」'。 –