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

Problem Statement: High Score Tracker ProgramObjective:
  • 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:
  1. 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.
  2. Vector Usage:

    • Use a std::vector to store the high scores.
    • The vector should be exactly the size specified by the user.
  3. Reading High Scores:

    • Prompt the user to enter each high score.
    • Assume the user will enter valid integers (no additional validation needed).
  4. Displaying Scores:

    • Implement a PrintVector function to display the contents of the vector.
  5. Sorting Scores:

    • Implement a function that sorts the vector in descending order (highest to lowest).
    • Call this function before displaying the sorted scores.
  6. 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.
  7. 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:


Valid Input Example:Enter the number of high scores: 3 Enter high score 1: 45 Enter high score 2: 89 Enter high score 3: 72 High Scores Unsorted45 89 72  High Scores Sorted89 72 45  
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

1 Expert Approved Answer
Step: 1 Unlock

Complete C Code for High Score Tracker Code Implementation maincpp include include include Utilityh ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Engineering Questions!