I'm trying to get the program to let me enter a users name and then a mark and display the average. This is what I've tried:
// 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);
}
}
I want it to ask for a name and then a mark ten times, and finally show the average. But it is only asking me for one name, after which it asks me for ten marks and gives me an average of these.