Ask Question, Ask an Expert

+61-413 786 465

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

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

  • 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

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As