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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education