Question: Problem Statement: High Score Tracker Program Objective: Create a C++ program that allows a user to enter a list of high scores, store them in
- Create a C++ program that allows a user to enter a list of high scores, store them in a vector, sort them in descending order, and display both the unsorted and sorted lists. The program should include proper input validation and adhere to the following constraints.
Requirements:
User Input:
- Ask the user how many high scores they want to enter.
- Validate the input to ensure the user enters a positive integer greater than zero.
Vector Usage:
- Use a std::vector to store the high scores.
- The vector should be exactly the size specified by the user.
Reading High Scores:
- Prompt the user to enter each high score.
- Assume the user will enter valid integers (no additional validation needed).
Displaying Scores:
- Implement a PrintVector function to display the contents of the vector.
Sorting Scores:
- Implement a function that sorts the vector in descending order (highest to lowest).
- Call this function before displaying the sorted scores.
Utility Class:
- Use a Utility class to handle input validation, sorting, and cleanup operations.
- Implement ReadInt() for input validation.
- Implement SortVectorHighToLow() to sort scores in descending order.
- Implement IsReadGood() to check if the input was valid.
Constraints:
- Do not use goto, continue, const, auto, resize(), ignore(), clear(), static_cast(), or pointers.
- Stick to basic data types and structures covered in the course materials.
Expected Sample Output:
Invalid Input Handling Example:Enter the number of high scores: -2 Invalid input. Please enter a positive integer. Enter the number of high scores: abc Invalid input. Please enter a positive integer. Enter the number of high scores: 3 Enter high score 1: 45 Enter high score 2: 78 Enter high score 3: 60 High Scores Unsorted45 78 60 High Scores Sorted78 60 45 Press any key to exit...
Step by Step Solution
There are 3 Steps involved in it
Complete C Code for High Score Tracker Code Implementation maincpp include include include Utilityh ... View full answer
Get step-by-step solutions from verified subject matter experts
