Write a program that records high-score data for a fictitious game. The program will ask the user to enter the number of scores, create two dynamic arrays sized accordingly, ask the user to enter the indicated number of names and scores, and then print the names and scores sorted by score in descending order. The output from your program should look exactly like this (given the same input): How many scores will you enter?: 4 Enter the name for score #1: Suzy Enter the score for score #1: 600 Enter the name for score #2: Kim Enter the score for score #2: 9900 Enter the name for score #3: Armando Enter the score for score #3: 8000 Enter the name for score #4: Tim Enter the score for score #4: 514 Top Scorers: Kim: 9900 Armando: 8000 Suzy: 600 Tim: 514 Additional Requirements The data must be stored in two dynamic arrays: an array of strings named names, and an array of ints named scores. These arrays must be declared and allocated using "new" in the main function. The user input of the names and scores should be done in a function named readData(). It should have the following signature: void readData(string names[], int scores[], int size) You must also write two more functions: one to sort both arrays in descending order by score, and one to display the final list of names and scores. They should have the following signatures. void sortData(string names[], int scores[], int size) void displayData(const string names[], const int scores[], int size) The main function should be very short. It should just get the number of scores, allocate the two arrays, invoke these three functions, and then deallocate the arrays.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter10: Pointers
Section: Chapter Questions
Problem 5PP
icon
Related questions
Question

Write a program that records high-score data for a fictitious game. The program will ask the user to enter the number of scores, create two dynamic arrays sized accordingly, ask the user to enter the indicated number of names and scores, and then print the names and scores sorted by score in descending order.

The output from your program should look exactly like this (given the same input):

How many scores will you enter?: 4 Enter the name for score #1: Suzy Enter the score for score #1: 600 Enter the name for score #2: Kim Enter the score for score #2: 9900 Enter the name for score #3: Armando Enter the score for score #3: 8000 Enter the name for score #4: Tim Enter the score for score #4: 514 Top Scorers: Kim: 9900 Armando: 8000 Suzy: 600 Tim: 514

Additional Requirements

The data must be stored in two dynamic arrays: an array of strings named names, and an array of ints named scores. These arrays must be declared and allocated using "new" in the main function.

The user input of the names and scores should be done in a function named readData(). It should have the following signature:

void readData(string names[], int scores[], int size)

You must also write two more functions: one to sort both arrays in descending order by score, and one to display the final list of names and scores. They should have the following signatures.

void sortData(string names[], int scores[], int size) void displayData(const string names[], const int scores[], int size)

The main function should be very short. It should just get the number of scores, allocate the two arrays, invoke these three functions, and then deallocate the arrays.

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning