Ask Question
21 October, 20:24

Write a program that prompts user to enter five numeric test score. the program should display the corresponding letter grade and class average

+2
Answers (1)
  1. 21 October, 23:12
    0
    import java. util. Scanner;

    public class Student {

    public static void main (String[ ] args) {

    //Enter 5 test scores

    int[ ] marks=enterMark ();

    //calculate average

    double averageScore=calAverage (marks);

    //calculate grade

    char theGrade=letterGrade (marks);

    //Display average

    System. out. println ("Average: " + average Score);

    //Display grade

    System. out. println (" Grade: " + theGrade);

    /* * method collects 5 test scores and returns reference*/

    public static int[ ] enterMark () {

    int[ ] arr=new int[5];

    //create Scanner object

    Scanner keyboard=new Scanner (System. in);

    int index=0;

    while (index
    System. out. print ("Enter test " + (index+1));

    arr[index]=keyboard. nextInt ();

    index++;

    }

    return arr;

    }

    /**method calculates and returns average*/

    public static double calAverage (int[ ] arr) {

    double total=0.0; / /to hold total

    double average=0.0; //hold average

    for (int count=0; count
    total+=arr[count];

    }

    average=total/arr. length;

    return average;

    }

    /* * method calculates and returns grade*/

    public static char letterGrade (double ave) {

    char grade; / /to hold grade

    if (ave >30)

    grade='D';

    if (ave >50)

    grade='C';

    if (ave > 60)

    grade='B';

    if (ave > 70)

    grade='A';

    else

    grade='F';

    return grade;

    }

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a program that prompts user to enter five numeric test score. the program should display the corresponding letter grade and class ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers