Ask Question
12 November, 13:27

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

+4
Answers (1)
  1. 12 November, 15:20
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers