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

program should be in JAVA , Thank you 2. Test Average and Grade Write a program

ID: 3911729 • Letter: P

Question

program should be in JAVA , Thank you

2. Test Average and Grade Write a program that asks the user to enter five test scores. The program should display a letter grade for each socre and the average test score. Write the following methods in the program: calcAverage : This method should accept five test scores as arguments and return the average of the scores determineGrade: This method should accept a test score as an argument and return a letter grade for the score, based on the following grading scales: Score 90-100 8 70-79 60-69 Below 60 Letter Grade

Explanation / Answer

import java.util.*;

import java.lang.*;

import java.io.*;

public class Solution

{

public static void main (String[] args)

{

Scanner s=new Scanner(System.in);

System.out.println("Enter 5 subjects Marks:");

int marks[]=new int[5];

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

{

marks[i]=s.nextInt();

}

System.out.println("Average of marks is "+ calcAcerage(marks));

System.out.println("Marks "+"Grade");

determineGrade(marks);

}

private static void determineGrade(int[] marks) {

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

{

System.out.println(marks[i]+" "+grade(marks[i]));

}

}

private static String grade(int i) {

if(i>100 || i<0)

return "Invalid";

else if(i>=90)

return "A";

else if(i>=80)

return "B";

else if(i>=70)

return "C";

else if(i>=60)

return "D";

else

return "F";

}

private static double calcAcerage(int[] marks) {

return (double)(marks[0]+marks[1]+marks[2]+marks[3]+marks[4])/5;

}

}

//Please Vote up if you find it helpful.Thanks.