Ejemplo n.º 1
0
 private static int range() {
   // Basic math, takes the min from the max and the result is the range of scores.
   int[] marks = Marks.getMarks();
   int maxMarks = max(marks);
   int minMarks = min(marks);
   int rangeOfMarks = maxMarks - minMarks;
   return rangeOfMarks;
 }
Ejemplo n.º 2
0
 public static void main(String[] args) {
   // The main function, primarily calls the other functions and displays their results.
   int[] marks = Marks.getMarks();
   System.out.println(max(marks));
   System.out.println(min(marks));
   System.out.println(range());
   System.out.println(mean(marks));
   System.out.println(median());
   System.out.println(mode(marks));
   System.out.println(grades(marks));
   System.out.println(gradeDistn(grades(marks)));
   // System.out.println(Arrays.toString(marks)); //Original array, used for testing purposes.
 }
Ejemplo n.º 3
0
 private static double median() {
   // Finds the median of the numbers
   int[] sortedMarks = Marks.getMarks();
   Arrays.sort(sortedMarks);
   double median;
   if (sortedMarks.length % 2 == 0) {
     median =
         ((double) sortedMarks[sortedMarks.length / 2]
                 + (double) sortedMarks[sortedMarks.length / 2 + 1])
             / 2;
   } else {
     median = (double) sortedMarks[sortedMarks.length / 2];
   }
   return median;
 }