Can I get some help making this C++ program. It requires every bullet to be it\'
ID: 3670951 • Letter: C
Question
Can I get some help making this C++ program. It requires every bullet to be it's own function.
You have been selected to write a program to calculate the scores for a local diving competition. There are 6 judges who are rating each diver on a scale of 1 to 10. Scores can be entered up to 2 decimal places. You are going to write a program that will read in the scores and determine the average score. Your program will also determine the highest and lowest score given to each diver. Your program should implement functions that perform the following tasks: Accept the data - function should prompt the user for the judge's score. Error checking should validate that it is in the range of 1 to 10. The function should be called for each of the scores. Determine the highest score - return the highest score of all the scores passed to the function Determine the lowest score - return the lowest score of all the scores passed to the function Average the scores - display the average score of all the scores passed to the function.Explanation / Answer
package eightscores;
import java.util.*;
import java.io.*;
import java.text.*;
public class EightScores {
public static void main(String[] args) {
Scanner input = new Scanner(System.in); // search for input
double[] scores = new double[8]; // set array scores to 8 values
double lowestScore = Double.MAX_VALUE;
double highestScore = Double.MIN_VALUE;
for(int i = 0; i <= 7; i++) // start for loop
{
System.out.print(String.format("Judge score #%d:", i + 1));
scores[i] = input.nextDouble();
if (scores[i] < lowestScore) {
lowestScore = scores[i];
}
if (scores[i] > highestScore) {
highestScore = scores[i];
}
}
double total = 0.00;
for(int i = 0; i < 8; i++) {
if (scores[i] != lowestScore && scores[i] != highestScore)
total = total + scores[i];
}
System.out.println("The lowest score entered is: " + lowestScore);
System.out.println("The highest score entered is: " + highestScore);
DecimalFormat format = new DecimalFormat("0.00");
System.out.println("Final Score: " + format.format(total));
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.