[英]“illegal start of type” when trying to calculate average in Java for 5 numbers
我在 Udacity Android 開發人員中進行了測試
public class MyCalculator {
int input1 = 10;
int input2 = 20;
int input3 = 30;
int input4 = 40;
int input5 = 50;
public float average() {
// TODO: write java code to calculate the average for all input variables
return 0;
}
}
我必須給出答案才能繼續學習,我已經嘗試了一切,但它沒有接受答案。 預計該方法計算結果為 30.0 作為float
。
錯誤:
| public float average(( input1 + input2 + input3 + input4 + input5)/5 ) {
illegal start of type
| System.out.print(average);
<identifier> expected
| System.out.print(average);
<identifier> expected
我在 Udacity Android 開發人員中進行了測試
public class MyCalculator {
int input1 = 10;
int input2 = 20;
int input3 = 30;
int input4 = 40;
int input5 = 50;
public float average() {
// TODO: write java code to calculate the average for all input variables
return 0;
}
}
我必須給出答案才能繼續學習,我已經嘗試了一切,但它沒有接受答案。 預計該方法計算結果為 30.0 作為float
。
錯誤:
| public float average(( input1 + input2 + input3 + input4 + input5)/5 ) {
illegal start of type
| System.out.print(average);
<identifier> expected
| System.out.print(average);
<identifier> expected
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.