Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete the code with the required instructions and execute * the program. */ #include using namespace std; // Method prototypes int menu(); bool execute(int, string[],

Complete the code with the required instructions and execute * the program. */ #include  using namespace std; // 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(){ // declare a string array named colors which contains the following values: // Yellow, Green, Red, Black, Blue, Purple // declare an integer named colorsCount and assign the size of colors // declare an integer constant named NUMBERS and initialize to 9 // declare an integer array named numbers using NUMBERS as the size, and // initialize all elements to 0 // call the randomAssign method to populate the numbers array // call the printNumbers method to print the values in the numbers array // call the orderNumbers method to order the values in numbers from high to low // call the printNumbers method to print the values in the numbers array // DO NOT DECLARE ANY OTHER VARIABLES IN main! // develop a while iteration control structure which uses the return value // of the execute method as sentinel. The execute method uses the return value of // the menu method as parameter, along with the names and sizes for the two arrays. cout << endl; // print the phrase "Program developed by [team member 1 name], ID#[team member 1 ID NUMBER HERE], // and [team member 2 name], ID#[team member 2 ID NUMBER HERE]" // where the square brackets and the text within must be replaced with your information cout << endl; system("pause"); // For Visual Studio only! return 0; } // The menu method prints a menu with the list of options. // The text to be printed is: // Select one of the following options: // 1. Find my lucky number // 2. Find my lucky color // 3. Exit the program // [blank line] // Your selection: // [blank line] // The method declares a local variable named option, which must be // initialized to 0, where the selected option value is stored. // The method returns the value of the selected option. // The execute method receives the option value, the two arrays, // and their respective sizes as parameters. It implmenets a switch // selection control structure to call the methods to find either the // lucky number or lucky color. // The method returns true unless the value of the option is 3, in this // case it returns false. Make sure to include the default case which // prints the error message " \tERROR! Incorrect option value! " // NO VARIABLES ARE DECLARED IN THIS METHOD // The getLuckyColor method receives an array of strings and its size // as parameters. It prompts the user for the lucky number using the // phrase "Enter your lucky number: ", and returns the corresponding color. // 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 select the // correct index number from the array. You must ensure that the value // entered is a positive value. // The getLuckyNumber 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 size of the array, to select the // correct index number from the array. You must ensure that the value // entered is a positive number. // The randomAssign method receives an array of integers and its size // 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 // 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 // return value. It prints the contents of the array using the phrase // "The random values stored in the array are: [first value], ..., [last value]." // Use a for iteration control structure to print the values, making sure that a comma and // a space are printed after all but the last values. A period and the end of line instruction // must be printed after the last value. Make sure to add a blank line after the phrase is printed. // The orderNumbers method receives an integer array and its size as parameters and has no // return value. It implements a bubble sort algorithm to order the values in the array // from highest to lowest. Declare the local integer variable temp and initialize to 0. The // only other variables declared are the counters for the iteration control structures.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions