c++ Because an official handicap requires up to 10 scores, you will need to modi
ID: 645742 • Letter: C
Question
c++
Because an official handicap requires up to 10 scores, you will need to modify the previous program to accept multiple scores, process the scores, and provide the user with their handicap.
Create a Do-While loop that runs up to 10 time that asks the user to enter up to 10 scores, which include the slope and rating for the course, and calculates the handicap for each score. You will need to use either parallel arrays or a two-dimensional array in order to store the score, slope and rating for each entry, and variables for the handicap accumulator and number of scores entered. The user will enter a 0 in score to exit the loop before entering 10 scores.
Once all scores have been entered, insert a new loop to read the array and display all of the scores. After you exit this loop, you need to display the average handicap.
Here is the previous program. Please help!
Main Module
Display
Explanation / Answer
import java.util.Scanner; public class GradeSystem { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); //forces the end of the program after calculation boolean end = true; //Creates a holder for the number of letter grades int A = 0; int B = 0; int C = 0; int D = 0; int F = 0; int HighScore = 0; int Loser = 0; System.out.println("Welcome to the grader-ator!"); do { System.out.println("Enter a grade from 0-100 or enter a negative number to quit."); // Gets the grades from the user int grade = keyboard.nextInt(); // If the grade is between a certain threshold, the number of letter grades is increased if (grade >= 93) { A++; } if (grade < 93 && grade >= 85) { B++; } if (grade < 85 && grade >= 77) { C++; } if (grade < 77 && grade >= 70) { D++; } if (grade < 70 && grade >= 0) { F++; } int average = 0; //Placeholder for the average int numberOfGrades = 0; //This keeps track of the number of grades that has been entered in while(grade >= 0) //Keeps program running as long as input > 0 { average += grade; //Adds the grade to the average. Also this is the same as saying average = average + grade numberOfGrades++;//increments the grade counter by 1 grade = keyboard.nextInt(); } average /= numberOfGrades; //Finds the average of the numbers System.out.println("Total number of grades is: "+numberOfGrades); System.out.println("Number of A's: "+A); System.out.println("Number of B's: "+B); System.out.println("Number of C's: "+C); System.out.println("Number of D's: "+D); System.out.println("Number of F's: "+F); System.out.println("Highest Score: "+HighScore); //what to put here System.out.println("Lowest Score: "+Loser); //what to put here System.out.println("Average Score: "+average); //ends the program }while (end = false); } }Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.