Processing information of person playing candy crush saga


Question 1) Write a program that would process a data set of information for a person that is playing Candy Crush Saga. The information woulkd be needed for later processing, so it would be stored in a set of arrays which will be displayed, sorted, and displayed (again).

Declare three arrays, each of which would hold a maximum of 400 elements:

• one array of integers to hold the level numbers

• one array of integers to hold the scores for each of the levels

• one array of integers to hold the number of stars that were earned for each level

The three arrays would be parallel arrays. This means that information for one level can be found in the same "spot" in each array. This also means that any time information is moved in one array the same move must be made to the other arrays in order to maintain data integrity.

Suggested Logic for main():

a) Declare three arrays of integers and an integer variable to hold the number of levels that have been completed. If any other variables are needed, those must also be declared.

b) Fill the three arrays by calling the buildArrays() function and put a value into the number of levels completed variable.

c) Display three arrays with the title "Candy Crush UNSORTED Report" by calling the printArrays()function.

d) Sort three arrays by calling the sortArrays() function.

e) Display three sorted arrays with title "Candy Crush SORTED Report" by calling the printArrays()function.

Functions to write and use

a) int buildArrays( int levelsArray[], int scoresArray[], int starsArray[] )

b) void printArrays( string reportTitle, int levelsArray[], int scoresArray[], int starsArray[], int numberOfLevels )

This function would display the information for the levels that have been completed. For each level, display the level number, the score for the level, and though many stars were earned for the level.

It takes five arguments: the first argument is a string which holds the title for the report that is being displayed, the second argument is an array of integers which holds the level numbers, the third argument is the array of integers which holds the scores for each level, the fourth argument is the array of integers which holds the number of stars for each level, and the fifth argument is an integer which holds the number of valid level that were placed in the arrays.

It returns nothing.

This function must be coded with the loop which executes numberOfLevels number of times. Within the loop, display the level number and score directly from second and third arguments, and then call printStars function to display the stars which were earned for the level. The printStars function must be passed the number of stars from the fourth argument.

Use the following as the basic format for the output:

Candy Crush UNSORTED report

Level         Score          Stars
----------------------------------
1              3840           ***
2              5940           ***
3             11560           ***
4             18140           ***
5             18780           ***

void printStars( int numberOfStars )

This function would display stars (asterisks) on the screen.

It takes one integer as its argument: the number of stars to display on the screen; and returns nothing.

This function must be coded with loop which executes numberOfStars number of times. Within the loop, display a single star (asterisk).
void sortArrays( int levelsArray[], int scoresArray[], int starsArray[], int numberOfLevels )

This function would use the selection sort algorithm that was presented in lecture to sort the arrays in ASCENDINGorder based on the scores for each level.

This function takes four arguments: the first argument is an array of integers which holds the level numbers, second argument is an array of integers which holds the scores for each level, the third argument is the array of integers that holds the number of stars for each level, and the fourth argument is an integer that holds the number of valid level that were placed in the arrays.

a) Each array must be able to hold 400 elements. Use a symbolic constant to represent the maximum size of the array.

b) Each array has a capability to hold 400 elements, though, that does not mean that they would all be used. This is the reason that number of elements in the array is being passed to the sort and print functions. This value is the return value from build Arrays.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Processing information of person playing candy crush saga
Reference No:- TGS04509

Expected delivery within 24 Hours