Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

If Method prototypen int menu() : bool execute(int, btring (1, const int, int (1, const int ) string gettuckyColor (strinig(l, const int): int getLuekykumber (int

image text in transcribed
image text in transcribed
image text in transcribed
If Method prototypen int menu() : bool execute(int, btring (1, const int, int (1, const int ) string gettuckyColor (strinig(l, const int): int getLuekykumber (int [1, cohat int): void randomkanign(int (], const int ); void printNumbers (int [] , const int ); void orderNumbera ( sint(), conet lnt); Int thain() ( (1 declare a string array named colors which contains the following values; 1/ Red, Green, Blue, Purple, Yellow, Black 1/ declare an integer named colorsCount and assign the sine of colors 1/ declare an integer constant named NUMBERS and initialize to 10 I/ declare an integer array named numbers using NUMBERs as the size, and 11 initialize all elements to 0 1/ call the randomAssign method to populate the numbers array 1/ call the printNumbers method to print the values in the numbers array 11 call the orderNumbers method to order the values in numbers from high to low 1/ call the printNumbers method to print the values in the numbers array I/ DO NOT DECLARE ANY OTHER VARIABLES IN main I I/ develop a while iteration control structure which uses the return value II of the execute method as 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 endl; 1/ print the phrase "Program developed by [team member 1 nane], ID\#[team member I ID NuMazR HERE 11 and [team member 2 name], ID\#[team member 2 ID NUMBER HERE]" I/ 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. I/ The text to be printed is: II Select one of the following options: 1. 1. Find my lucky number 2. Find my lueky color 3. Exit the program [l [blank line] 1/ Your selection: II [blank line] If The method declares a local variable named option, which must be 1/ initialized to 0 , where the selected option value is stored. // The method returns the value of the selected option. /1. The execute method receives the option value, the two arrays, /1 and their respective sizes as parameters. It implmenets a switch II selection control structure to call the methods to find either the // lucky number or lucky color. 11 The method returns true unless the value of the option is 3 , in this 1/ case it returns false. Make sure to include the default case which 1/ prints the error message "In ItERROR! Incorrect option value! n " I/ NO VARIABLES ARE DECLARED IN THIS METHOD 11. The gettuckycolor method receives an array of strings and its size 1/ as parameters. It prompts the user for the lucky number using the 1/ phrase "Enter your lucky number: ", and returns the corresponding color. // Declare an integer variable named number and initialize it to 0 . 1/ The method uses the value of the number, modulus the size of the array, to select the 1/ correct index number from the array. You must ensure that the value // entered is a positive value. 1/ The getLuckyNumber method receives an array of integers and its size 1/ as parameters. It prompts the user for their day of birth using the /1 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 size of the array, to select the 1/ correct index number from the array. You must ensure that the value I/ entered is a positive number. 1/ The randompsign method receives an array of integers and its size 1/ as parameters. It assigns a random value in the range of 1 to 99 to // each element of the array. Make sure to seed the pseudo random number generator 11 with the return value of the time method, casting the value as required. // The only variable declared is the counter for the iteration control structure. // The printNumbers method receives an integer array and its size as parameters and has no 1/ return value. It prints the contents of the array using the phrase 1/ "The random values stored in the array are: [first value], .., [last value]." I/ Use a for iteration control strueture to print the values, making sure that a conma and 1/ a space are printed after al1 but the last values. A period and the end of 1 ine instruetion /f must be printed after the last value. Make sure to add a blank line after the phrase is printed. 1/ The orderNumbers method receives an integer array and its size as parameters and has no I/ return value. It implements a bubble sort algorithm to order the values in the array /f from highest to lowest. Declare the local integer variable temp and initialize to 0 . The /I only other variables declared are the counters for the iteration control struetures

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

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions

Question

foundations of finance mini cases chapter 9 problem b

Answered: 1 week ago

Question

Apply your own composing style to personalize your messages.

Answered: 1 week ago

Question

Format memos and e-mail properly.

Answered: 1 week ago