Java Assignment - Arrays 1


Write a program that will read an unknown number of marks (out of 100), quitting when reading a sentinel of -1 is read.  Assume the marks are whole numbers.  Output an error message for marks above 100.

 

(a) Calculate and display the arithmetic mean of the marks.  The mean is the sum of all marks divided by the number of marks.  Round your result to one decimal place.

 

(b) Determine the mode of the marks.  The mode of a group of values is the value that occurs most often in the group.  A group may have more than one mode if more than one value occurs with the maximum frequency.

 

(c) Determine the median of the marks.  If there is an odd number of marks, the median is the middle one.  If there is an even number of values, the meadian is the mean of the two scores on either side of the middle.

 

10 20 30 has a median of 20

10 20 30 40 has a median of 25 (the mean of 20 and 30)