Question
Assignment 1.2 [25 points] Write a program that records high-score data for a fictitious game. The program will ask the user to enter the number
Assignment 1.2 [25 points]
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 initializeArrays(). It should have the following signature:
void initializeArrays(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, and then invoke these three functions.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started