Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include using namespace std; I/ Method prototypes int menu(); bool execute(int, string[], const int, int[], const int); string getLuckyColor(string[], const int); int getLuckyNumber(int [], const

image text in transcribed
image text in transcribed
image text in transcribed
\#include using namespace std; I/ Method prototypes int menu(); bool execute(int, string[], const int, int[], const int); string getLuckyColor(string[], const int); int getLuckyNumber(int [], const int); void randomAssign(int [], const int); void printNumbers (int [ ] , const int); void orderNumbers (int [ ] , const int); int main()\{ /f declare a string array named colors which contains the following values: // Red, Green, Blue, Purple, Yellow, Black If declare an integer named colorscount and assign the size of colors // declare an integer constant named NUMBERS and initialize to 10 1/ declare an integer array named numbers using NUMBERS as the size, and // initialize all elements to 0 1/cal1 the randomAssign method to populate the numbers array If call the printNumbers method to print the values in the numbers array 1f call the orderNumbers method to order the values in numbers from high to low II call the printNumbers method to print the values in the numbers array I/ DO NOT DECLARE ANY OTHER VARIABLES IN main! I/ develop a while iteration control structure which uses the return value I/ of the execute method an sentinel. The execute method uses the return value of 1/ the menu method as parameter, along with the names and sizes for the two arrays. cout endi; II print the phrase "Program developed by [team member 1 name], ID\#[team member 1 ID NOMBER HERE], 1/ and [team member 2 nane], ID\# [team member 2 ID NUMBER HERE]" 1/ where the square brackets and the text within must be replaced with your information cout endl; system("pause"); |/ For Visual studio only! return 0 ; I The menu method prints a menu with the list of options. If The text to be printed is: If Select one of the following options: 1. Find =y lucky number 2. Find my lueky color 3. Exit the program [blank 1ine] Your selection: [blank 1ine] II The method declares a loeal variable named option, which must be II initialized to 0 , where the selected option value is stored. // The method returns the value of the selected option. If The execute method receives the option value, the two arrays, 1f and their respective sizes as paraseters. It implmenets a switch If selection control structure to call the methods to find either the II lucky number or lueky color. 1f. The method returns true unless the value of the option is 3, in this I/ case it returns talse. Make sure to include the default case which I/ NO VARIABLES ARE DECLARED IN THIS METHOD If The gettuckycolor method receives an array of strings and its size If as paraneters. It prompts the user for the lucky number using the 1/ phrase "Enter your lueky number; ", and returns the corresponding color. 1/ Declare an integer variable named number and initialize it to 0 . // The method uses the value of the number, modulus the size of the array, to solect the If correct index number from the array. You must ensure that the value // entered is a positive value. The gethuckyNumber method receives an array of integers and its size as parameters. It prompts the user for their day of birth using the phrase "Enter your day of birth: ", and returns the corresponding number. Declare an integer variable named birthday and initialize it to 0 . The method use the value of the birthday, modulus the aize of the array, to select the 1f correct index number from the array. You must ensure that the value II entered is a positive number. 11. The randomksign method receives an array of integers and its aize 11 as parameters. It assigns a random value in the range of 1 to 99 to 11 each elenent of the array. Make sure to seed the pseudo random nuaber generator II with the return value of the time method, casting the valte as required. /I The only varioble declared is the counter for the lteration control structure. 1) The printhumbern method receiven an integer array and its sise as paraneters and has no 11 return value. It prints the contents of the array using the phrase 1f "The randos values stored in the array are i [firat value], ..., [last value]." 1/ Ose in for iteration control structure to print the values, making aure that a comma and II n npace are printed after al.1 but the last values. A period and the end of fine Instruetion II munt be printed after the last value. Make sure to add a blank 1fse after the phrase ia printed. II the orderthumbere method recelves an integer array and it n sire as paranetera and has no 1/ return value. It implements a bubble nort algorithn to order the values in the array 1/ tron highent to lovest. Declere the loeal integer variable tenp and initialire to 0 . The 1/ only other variables dechared are the counters for the iteration control strueturas

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Assess three steps in the selection process.

Answered: 1 week ago

Question

Identify the steps in job analysis.

Answered: 1 week ago