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++

Assignmentconsider the following declarationsclass

Assignment Consider the following declarations: class bagType { public: void set(string, double, double, double, double); void print() const; string getStyle() const; double getPrice() const; void get(double, double, dou ...

Write a c application that does the followingitem 1 prompts

Write a C++ application that does the following: ITEM 1: Prompts the user to choose one of the following series: 1 + 1/2 + 1/3 + ... + 1/n ((((x * 2) * 2) * ...) * 2) series of n multiplications x + (x * 1) + (x * 2) + ( ...

Bankers algorithmimplement the bankers algorithm for

Banker's Algorithm Implement the Banker's algorithm for deadlock avoidance, that works on a given set of N processes and M resource types (N The input data and result is then displayed on the screen. You may use your pro ...

Write a c program that calculates and prints the average of

Write a C program that calculates and prints the average of two or more salaries entered by the user. The program should first prompt the user to enter the number of salaries to process (make sure: at least 2 salaries mu ...

Design implement test and debug a c program to simulate the

Design, implement, test, and debug a C# program to simulate the rolling of two dice 100 times. Whenever the two dice display the same number, the program should show the roll sequence number (e.g. the 10th roll) and the ...

Cs 2410workshop make-up assignmentwrite a c program that

CS 2410 Workshop Make-Up Assignment Write a C++ program that will output to a file called output.txt EVERY 10 digit phone number from 713-000-0000 through 713-000-0998. These numbers MUST only contain an odd number of ev ...

Discussionwhile loops versus for loops please respond to

Discussion "While Loops versus For Loops" Please respond to the following: • Suppose you are writing a C++ program that plays a commercial video continuously within a kiosk at your favorite shopping mall within your home ...

Modules in c are called functions c programs are typically

Modules in C are called functions. C programs are typically written by combining user created functions as well as "pre-packaged" functions found in the C Standard Library. For instance, printf() is a function that is fo ...

Programming in c assignmentwrite a c program that computes

Programming in C Assignment Write a C program that computes and outputs the current age of the United States in days (you can use 1776 as theUS founding year). You don't have to worry about fractional years or leap years ...

Programming assignment 5write a c program that allows the

PROGRAMMING ASSIGNMENT #5 Write a C program that allows the user to make some banking transactions. The program should first prompt the user to enter the current balance of his/her bank account (in dollars and cents, not ...

  • 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

WalMart Identification of theory and critical discussion

Drawing on the prescribed text and/or relevant academic literature, produce a paper which discusses the nature of group

Section onea in an atwood machine suppose two objects of

SECTION ONE (a) In an Atwood Machine, suppose two objects of unequal mass are hung vertically over a frictionless

Part 1you work in hr for a company that operates a factory

Part 1: You work in HR for a company that operates a factory manufacturing fiberglass. There are several hundred empl

Details on advanced accounting paperthis paper is intended

DETAILS ON ADVANCED ACCOUNTING PAPER This paper is intended for students to apply the theoretical knowledge around ac

Create a provider database and related reports and queries

Create a provider database and related reports and queries to capture contact information for potential PC component pro