Ask Question, Ask an Expert

+1-415-315-9853

info@mywordsolution.com

Ask C/C++ Expert


Home >> C/C++

problem 1) prepare 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 prepare 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.

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M94509

Have any Question? 


Related Questions in C/C++

Descriptionnbspin this assignment you will write a c

Description:  In this assignment you will write a C++ program that finds the kth largest number among a set of N numbers. It will implement the solution using two different algorithms and measure the time elapsed during ...

Pa 1 word countertabulating basic document statistics is an

PA #1: Word Counter Tabulating basic document statistics is an interesting exercise that leverages your knowledge of strings, files, loops, and arrays. In this homework, you must write a C++ program that asks the user fo ...

Write code to create the generator submit your source code

Write code to create the generator. Submit your source code as well as a description of how I could run the program, sample screenshots of the program in action, and the various changes that could be produced through you ...

Writeacprogramthatwilluseloopstoperformeachofthefollowingtas

Write a C++ program that will use loops to perform each of the following tasks: 1. Ask the user for two characters from the keyboard and read them into char variables. Determine which input is larger and which is smaller ...

Computer programmingobjectives1 opening a file reading from

Computer Programming Objectives: 1. Opening a file, reading from file, writing to a file and closing a file. 2. Sequential access files handling. 3. Practice C++ programming problems. Note: Carefully read the following i ...

More often than not entrepreneurs will fail several times

"More often than not, entrepreneurs will fail several times before they make it and will usually learn a lot in the process. To help these entrepreneurs to succeed will require a cultural shift. We need to encourage Aust ...

1 requirementsin this assignment you can unleash your

1. REQUIREMENTS In this assignment, you can unleash your imaginations and use OpenGL with C/C++ programming to produce a scene(s) that represents what you envision could possibly be seen under the sea. Please note that a ...

1 write a program to find the sum amp average of the given

1) Write a program to find the sum & average of the given numbers using the while loop. 2) Write a program in C to find the sum and average of the given numbers stored in an array of n values.

C program codeoverviewfor this assignment write a program

C++ program code Overview For this assignment, write a program that will simulate a single game of Craps. Craps is a game of chance where a player (the shooter) will roll 2 six-sided dice. The sum of the die will determi ...

Computer programming assignment-q1 using for loop write a c

Computer Programming Assignment- Q1. Using for loop, write a C++ program that prints out the multiples of 3 up through 75, separated by a blank space.  3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60 63 66 69 72 ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

A cola-dispensing machine is set to dispense 9 ounces of

A cola-dispensing machine is set to dispense 9 ounces of cola per cup, with a standard deviation of 1.0 ounce. The manuf

What is marketingbullwhat is marketing think back to your

What is Marketing? • "What is marketing"? Think back to your impressions before you started this class versus how you

Question -your client david smith runs a small it

QUESTION - Your client, David Smith runs a small IT consulting business specialising in computer software and techno

Inspection of a random sample of 22 aircraft showed that 15

Inspection of a random sample of 22 aircraft showed that 15 needed repairs to fix a wiring problem that might compromise

Effective hrmquestionhow can an effective hrm system help

Effective HRM Question How can an effective HRM system help facilitate the achievement of an organization's strate