Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a Java Class that reads students grades and assigns grades based on the fo

ID: 3882103 • Letter: W

Question

Write a Java Class that reads students grades and assigns grades based on the following grading “curve”:

Assigned date: 2/1/2018 Due Date: 2/8/2018 Concepts: Methods and one dimensional Arrays Point value: 45 points Write a Java Class that reads students grades and assigns grades based on the following grading curve": Grade is A if the score is greater than or equal to the highest score - 10 Grade is B if the score is greater than or equal to the highest score - 20 Grade is C if the score is greater than or equal to the highest score-30 Grade is D if the score is greater than or equal to the highest score - 40 Grade is F otherwise So, for example, after all grades are entered, if the highest grade entered was a 92, then: · A >= 82 . B >= 72 .C62 D >= 52 F otherwise The program will do the following: Prompt the user for the number of grades to be entered. The grades will all be integers .Read in the grades and store them in an array of the correct size .Call the method below (which you will create) to calculate and return the highest value in the Array public static int findMax(int] theArray) Call the method below (which you will create) to print a line for each grade in the format displayed in the sample output on next page: public static void printGrades (int[] theArray, int highestGrade)

Explanation / Answer

import java.util.Scanner;

public class Grade {

  

   public static int findMax(int[] theArray) {

      

       int max = theArray[0];

       for(int i=1; i<theArray.length; i++)

           if(theArray[i] > max)

               max = theArray[i];

       return max;

   }

  

   public static void printGrades(int[] theArray, int higestGrade) {

      

       for(int i=0; i<theArray.length; i++) {

          

           char ltr = 'A';

          

           if(theArray[i] >= Math.abs(higestGrade- 10))

               ltr = 'D';

           else if(theArray[i] >= Math.abs(higestGrade - 20))

               ltr = 'C';

           else if(theArray[i] >= Math.abs(higestGrade - 30))

               ltr = 'B';

           else if(theArray[i] >= Math.abs(higestGrade - 40))

               ltr = 'A';

           else

               ltr = 'F';

          

           System.out.println("Student "+i+" score is "+theArray[i]+" and grade is "+ltr);

       }

   }

  

   public static void main(String[] args) {

      

       Scanner sc = new Scanner(System.in);

      

       System.out.println("Enter the number of grades");

       int n = sc.nextInt();

      

       // creating an array

       int[] grades = new int[n];

      

      

       // reading grades

       System.out.println("Enter 4 grades separated by space");

      

       for(int i=0; i<n; i++)

           grades[i] = sc.nextInt();

      

       sc.close();

      

       int max = findMax(grades);

      

       //System.out.println(max);

      

       printGrades(grades, max);

   }

}

/*

Sample run:

Enter the number of grades

4

Enter 4 grades separated by space

40 55 70 85

Student 0 score is 40 and grade is F

Student 1 score is 55 and grade is B

Student 2 score is 70 and grade is C

Student 3 score is 85 and grade is D

*/