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

Write a program which takes the grades from ten quizzes and computes the average

ID: 3816048 • Letter: W

Question

Write a program which takes the grades from ten quizzes and computes the average quiz score. However, the teacher usually drops the lowest two scores. You must take this into consideration when computing the average quiz grade. Your program must implement the following methods: readQuizScore: This method asks and reads one quiz score from the console, validates the score, and then returns the score. This method will be called once for each score. computeAverage: This method takes the ten scores as input, computes the average, and returns the average. getLowestScore: This method takes the ten scores as input and returns the lowest score of the tens cores. getSecondLowestScore: This method takes the ten scores as input, and returns the second lowest score of the ten scores. Display the two lowest scores, and the correct average. Input Validation Each score must be a positive value between 0.0 and 100.0 Requirements: All four of the required methods must be implemented, and all must be correctly used within your program to get credit. Round the solution to two decimal places. You are only allowed to ask the user to enter the 10 scores once. You will need to figure out how to pass the scores to your methods in order to find the solution. Sample Execution:

Explanation / Answer

import java.util.*;


public class Quiz
{

public static void main(String[] args)
{
  
ArrayList<Float> arr_score=new ArrayList<Float>();
   Scanner sc=new Scanner(System.in);

System.out.println("Enter the ten scores:");
  
for(int i=0;i<10;i++)
{
float f = sc.nextFloat();
float score = readQuizScore(f);
if(score<0)
{
System.out.println("Enter valid score between 0 and 100");
i=i-1;
}
else
{
arr_score.add(score);
}
  
}
float l1 = getLowestScore(arr_score);
float l2 = getSecondLowestScore(arr_score);
arr_score.remove(l1);
arr_score.remove(l2);
  
System.out.println("Two Lowest Scores : "+ l1 + "and " + l2);
  
float avg = computeAverage(arr_score);
System.out.println("Average : " + avg);
}
  
public static float readQuizScore(Float score)
{
if(score < 0 && score>100)
return -1;
else
return score;
}
public static float computeAverage(ArrayList<Float> arr_score)
{
float avg, temp;
float total =0;
int count =0;
Iterator itr=arr_score.iterator();
   while(itr.hasNext())
   {
temp = (Float)itr.next();
   total = total + temp;
count = count + 1;
   }
  
   avg = total / count;
return avg;
}
public static float getLowestScore(ArrayList<Float> arr_score)
{
  
Float smallest = Collections.min(arr_score);
  
return smallest;
}
public static float getSecondLowestScore(ArrayList<Float> arr_score)
{
ArrayList<Float> copy = new ArrayList<Float>(arr_score);
  
Float smallest = Collections.min(copy);
copy.remove(smallest);
Float secondSmallest = Collections.min(copy);
  
return secondSmallest;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote