Using the following array: //may be declared outside of the main function const int NUM_Games =4; //may only...

80.2K

Verified Solution

Question

Programming

Using the following array:

//may be declared outside of the main function

const int NUM_Games =4;

//may only be declared within the main function

int scores[NUM_GAMES] = {122, 76, 92, 143};

Write a C++ program to run a menu-driven program with thefollowing choices:

1) Display the scores
2) Change a score
3) Display game with the highest score
4) Display a sorted list of the scores
5) Quit

  • Write a function called getValidScore that allows a user toenter in an integer and loops until a valid number that is>= 0and <= 150 is entered. It returns the valid value.
    • int getValidScore();
  • Write a function called getValidGameNumber that allows a userto enter in an integer and loops until a valid number that is>=1 and <= NUM_GAMES. It returns the valid value.
    • int getValidGame();
  • Write a function called displayScores that takes the scorearray as a parameter and displays the scores in the format in thesample run below.
    • void displayScores(int scores[NUM_GAMES]);
  • Write a function called ChangeAScore that takes the score arrayas a parameter, it allows the user to enter in a valid score and avalid game, It then stores the score under the selected game in thescores array.
    • void ChangeAScore(int scores[NUM_GAMES]);
  • Write a function called displayGameHighestScore that takes thescore array as a parameter, it displays the number of the game withthe highest score. Note: array elements are 0 to 2 but the gamenumbers are 1 to 5.
    • //displays the number of the game with the highest score
    • void displayGameHighestScore(int scores[NUM_GAMES]);
  • Write a function called displaySortedScores that takes thescores array as a parameter, it creates a local copy of the scoresarray, sorts the new array in descending order and displays valuesin the new array. You can use either bubble or selection sort.
    • void displaySortedScores(int scores[NUM_GAMES]);

Sample Run:

Welcome to the Gaming Program!

1) Display the scores

2) Change a score

3) Display game with the highest score

4) Display a sorted list of the scores to the menu

5) Quit

Select an option (1..4)..1

Display scores

Game 1           Game 2           Game 3           Game4

   122                 76                  92                    143

1) Display the scores

2) Change a score

3) Display game with the highest score

4) Display a sorted list of the scores to the menu

5) Quit
Select an option (1..4)..2

Change a score

Please enter in the game number …

20

Please enter in a valid game number …

2

Please enter in the score ...

135

1) Display the scores

2) Change a score

3) Display game with the highest score

4) Display a sorted list of the scores to the menu

5) Quit
Select an option (1..4)..3

The game with the highest score is 4

Select an option (1..4)..4

Sorted list of scores

143     135      122     92

Select an option (1..4)..5

Answer & Explanation Solved by verified expert
4.2 Ratings (600 Votes)
Screenshot ofprogram codeScreenshot ofoutputProgram code tocopyinclude using    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students