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

use no arrays language used: java Write a program which takes the grades from te

ID: 3706011 • Letter: U

Question

use no arrays
language used: java

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. . get SecondLowestscore: 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: Enter the ten scores: 100.0 78.45 89.23 98.00 67.87 88.29 82.67 87.50 90.56 94.38 Two Lowest scores: 67.87 and 78.45 Average: 91.33

Explanation / Answer

QuizScores.java

import java.util.ArrayList;

import java.util.Scanner;

public class QuizScores {

static Scanner scan = new Scanner(System.in);

public static void main(String[] args) {

ArrayList<Double> list = new ArrayList<Double>();

System.out.println("Enter the ten scores: ");

for(int i=0;i<10;i++) {

list.add(readQuizScore());

}

System.out.println("Two Lowest Scores: "+getLowestScore(list)+" and "+getSecondLowestScore(list));

System.out.printf("Average: %.2f ",computeAverage(list));

}

public static double readQuizScore() {

double score = scan.nextDouble();

while(score<0 || score>100) {

System.out.print("Invalid Score. ");

score = scan.nextDouble();

}

return score;

}

public static double computeAverage(ArrayList<Double> list) {

double sum = 0;

for(int i=0;i<list.size();i++) {

sum+=list.get(i);

}

return sum/list.size();

}

public static double getLowestScore(ArrayList<Double> list) {

double min = list.get(0);

for(int i=1;i<list.size();i++) {

if(min>list.get(i)) {

min = list.get(i);

}

}

return min;

}

public static double getSecondLowestScore(ArrayList<Double> list) {

double firstMin = list.get(0);

double secondMin = list.get(0);

for(int i=1;i<list.size();i++) {

if (list.get(i) < firstMin) {

secondMin = firstMin;

firstMin = list.get(i);

} else if (list.get(i) < secondMin && list.get(i) > firstMin) {

secondMin = list.get(i);

}

}

return secondMin;

}

}

Output:

Enter the ten scores:
100 78.45 89.23 98.00 67.87 88.29 82.67 87.5 90.56 94.38
Two Lowest Scores: 67.87 and 78.45
Average: 87.695