我试图让程序让我输入用户名称,然后标记并显示平均值。这是我试过的:为什么我的考试没有将平均代码工作?
// Calculate Students Average of series of exam marks stored in an array
import uulib.GUI;
public class ExamMarks {
public static void main(String[] args) {
final int SIZE = 10;
int[] marks = new int[SIZE];
double total, average;
String[] names = new String[]{""};
// Read marks into array
{
String name;
name = GUI.getString("Enter your name");
GUI.show("Names");
}
for(int i=0; i<marks.length; i++) {
marks[i] = GUI.getInt("Enter mark " + (i+1));
}
total = 0;
// calculate average mark
for(int i=0; i<marks.length; i++) {
total = total + marks[i];
}
average = total/SIZE;
GUI.show("Average mark is " + average);
}
}
我希望它要求一个名字,然后标记十次,最后显示平均值。但它只是要求我提供一个名字,之后它会问我十个分数,并给我一个平均值。
寻求帮助的可怕方法。 – pstanton 2009-12-08 11:02:58
它是做什么的? – nes1983 2009-12-08 11:08:44
还有什么其他的方式可以问我一个我会 – 2009-12-08 11:08:59