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

Create your own unique while-end repetition structure you

Create your own unique While-End repetition structure. You decide the theme. You should provide both the pseudocode and the flowchart of your example. Be sure to provide an overview of what your repetition structure is d ...

Object-oriented programming assignmentintroduction -nbspa

Object-Oriented Programming Assignment Introduction -  "A logical matrix or (0, 1) matrix is a matrix with entries from the Boolean domain B = {0, 1}. Such a matrix can be used to represent a binary relation between a pa ...

Intro to programming in c assignmentsince this is the last

Intro to Programming in C Assignment Since this is the last assignment, there will be no late submission. All programs must be electronically submitted by 5:00pm on Tuesday, December 2nd with NO EXCEPTIONS in order to re ...

C-programmingcreate a c program that sorts a sequence of

C-Programming Create a C program that sorts a sequence of positive numbers using the bubble sort algorithm in an increasing or decreasing order based on the user's choice. The pseudo code for the bubble sort algorithm is ...

Transaction processing system tpsxyz electronics is one of

Transaction Processing System (TPS) XYZ Electronics is one of the most popular electronics companies In Sultanate of Oman the company offers affordable electronic gadgets such as mp3 players, portable movie players, mobi ...

Write a console-based c program that can be used as a math

Write a console-based C++ program that can be used as a math tutor for a young student. The program should display two random numbers consisting of three digits each to be added in columnar format, such as: 247 +129 ---- ...

1 three employees in a company are up special pay increase

1. Three employees in a company are up special pay increase. You are given a file, with the following data: Miller Andrew 65789.87 5 Green Sheila 75892.56 6 Sethi Amit 74900.50 6.1 Each input line consists of an employee ...

1 we know that from ece 109 to calculate the

1. We know that from ECE 109, to calculate the equivalent resistance of a network of resistors in series in parallel are given by: Write a C++ program that asks the user to input values for resistors (as many as they wou ...

Practice with pointers and dynamic memory

Practice with pointers and dynamic memory allocation Problem: Write a C++ program that will implement and test the four functions described below that use pointers and dynamic memory allocation. The Functions: You will w ...

Write a program that reads numbers from cin and then sums

Write a program that reads numbers from cin and then sums them, stopping when 0 has been entered. Construct three versions of this program, using the while ,do - while , and for loops. Add the following to your program: ...

  • 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