Ask Question
22 January, 19:42

Write a complete Java program to: 1. prompt the user to enter all of his/her quiz scores. 2. calculate and display the average entered quiz score without the the lowest quiz score

+5
Answers (1)
  1. 22 January, 21:47
    0
    Here is code in java.

    import java. util.*;

    import java. lang.*;

    import java. io.*;

    / / main class

    class Main

    {

    public static void main (String[] args) throws java. lang. Exception

    {

    try{

    / / declare variables

    int n;

    float m=Float. MAX_VALUE;

    float sum=0, avg;

    / / Scanner class object to read input

    Scanner sc=new Scanner (System. in);

    System. out. println ("Enter the Number of quiz:");

    / / read Number of quiz

    n=sc. nextInt ();

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

    {

    System. out. println ("Enter the score of quiz "+i+":");

    //read score of each quiz

    float x=sc. nextFloat ();

    / / calculate sum of all quiz

    sum=sum+x;

    //find the lowest quiz score

    if (x
    m=x;

    }

    / / subtract the lowest quiz score

    sum=sum-m;

    / / find the Average

    avg=sum / (n-1);

    System. out. println ("Average of " + (n-1) + " quiz without lowest quiz is: "+avg);

    }catch (Exception ex) {

    return; }

    }

    }

    Explanation:

    First read the Number of quiz and assign it to variable "n". Then read n Numbers of quiz score and calculate their sum. Find the minimum score and subtract it from the total sum of all quiz. then find the Average of n-1 Numbers and print the Output.

    Output:

    Enter the Number of quiz:

    5

    Enter the score of quiz 1:

    1.2

    Enter the score of quiz 2:

    3.0

    Enter the score of quiz 3:

    5

    Enter the score of quiz 4:

    9

    Enter the score of quiz 5:

    4.5

    Average of 4 quiz without lowest quiz is: 5.375
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a complete Java program to: 1. prompt the user to enter all of his/her quiz scores. 2. calculate and display the average entered quiz ...” 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