[英]“illegal start of type” when trying to calculate average in Java for 5 numbers
I have test in Udacity Android developer我在 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;
}
}
I must give answer to continue study and I have been try everything and it did not accept the answer.我必须给出答案才能继续学习,我已经尝试了一切,但它没有接受答案。 It is expected that the method calculates a result of 30.0 as a
float
.预计该方法计算结果为 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
I have test in Udacity Android developer我在 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;
}
}
I must give answer to continue study and I have been try everything and it did not accept the answer.我必须给出答案才能继续学习,我已经尝试了一切,但它没有接受答案。 It is expected that the method calculates a result of 30.0 as a
float
.预计该方法计算结果为 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.