Ask Question
16 October, 22:03

Write an application that allows a user to enter any number of student quiz scores until the user enters 99. If the score entered is less than 0 or more than 10, display an appropriate message and do not use the score. After all the scores have been entered, display the number of scores entered, the highest score, the lowest score, and the arithmetic average. Save the file as QuizScoreStatistics. java.

+3
Answers (1)
  1. 16 October, 22:08
    0
    import java. util. Scanner;

    import java. util.*;

    import java. util. Collections;

    class Main

    {

    public static void main (String[] args)

    {

    List Scores = new ArrayList ();

    Scanner sc1=new Scanner (System. in);

    int i = 0;

    int a=0;

    do

    {

    System. out. println ("Enter score");

    a = sc1. nextInt ();

    if (a < = 0)

    {

    System. out. println ("You entered wrong score");

    continue;

    }

    else if (a 0)

    {

    System. out. println ("You entered wrong score");

    continue;

    }

    else

    {

    Scores. add (a);

    }

    i++;

    }while (a!=99);

    int max = Collections. max (Scores);

    int min=Collections. min (Scores);

    int sum=0;

    float averg = 0;

    for (i=0; i<=Scores. size () - 1; i++)

    {

    sum + = Scores. get (i);

    }

    averg = sum/Scores. size ();

    System. out. println ("Maximum score" + max);

    System. out. println ("Minimum score"+min);

    System. out. println ("Average:"+averg);

    }

    }

    Explanation:

    Remember we need to use Arraylist and not array, as we do not know how many scores we are going to have. And we use Collections for this, where we have functions for finding maximum and minimum for arraylist, however, for average, we need to calculate. However, one should know that Arraylist has better options available as compare to arrays.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write an application that allows a user to enter any number of student quiz scores until the user enters 99. If the score entered is less ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers