Question: Define constants for the following: ( all constants should be int ) array size - value is 1 0 0 minimum value to initialize array

Define constants for the following: (all constants should be int)
array size - value is 100minimum value to initialize array with - value is 0maximum value to initialize array with - value is 100menu options for the following:
Display all array contentsDisplay lower valuesDisplay higher valuesDisplay averageQuit program
Define prototypes for the following functions:
initializeArray: This function does not return a value and accepts 2 parameters - the array and its size. It initializes the array with random numbers between 0 and 100getMenuChoice: This function does not accept any parameters and returns an int. It displays the menu and returns the user's menu choice.processMenuChoice: This function accepts 3 parameters - the user's choice, the array, and its size. The function does not return a value. It calls the appropriate function based on the choice parameter.displayArray: This function accepts 2 parameters - the array and its size. The function displays each element of the array to the console.displayLower: This function accepts 3 parameters - the array, its size, and a number. The function display all elements of the array that are less than its number parameter.displayHigher: This function accepts 3 parameters - the array, its size, and a number. The function display all elements of the array that are higher than its number parameter.displayAverage: This function accepts 2 parameters - the array and its size. It calculates and displays the average of all elements in the array.You will need the following tool functions from tools.cpp:
getInt()getBoundedInt()flushInput()randomInt()
Main implementation
Define an array of integers and a size of 100
int array[ARRAY_SIZE];
Initialize the array, call initializeArray()Create a do/while(true) loop. Within the loop, do the following
Display the menu and get the user's choice, call getMenuChoice()Break out of the loop if the choice is quitProcess the menu choice - call processMenuChoice passing the choice, array, and array size
InitializeArray implementation
Create a for loop that walks through each element of the array. For example:
for (int index =0; index < size; index++)
Within the loop, initialize the array element. For example:
array[index]= randomInt(MIN_VALUE, MAX_VALUE);
getMenuChoice implementation
Create cout statements that display the menuget and return the user's choice - call the getBoundedInt function
processMenuChoice implementation
Define a local int variable that will be used to get a number from the userCreate a switch statement with a case statement for each menu option
display all - call the displayArray function passing the array and size parametersdisplay lower:
prompt the user to enter a number - call getBoundedIntcall the displayLower function passing the array, size, and number arguments
display higher:
prompt the user to enter a number - call getBoundedIntcall the displayHigher function passing the array, size, and number arguments
average
call the displayAverage function passing the array and size arguments
quit
break out of the switch statement
default
display an error message indicating invalid menu choice
displayArray implementation
Create a for loop that walks through each element of the array similar to the for loop used in the initalizeArray function.
output the array element: cout << setw(5)<< array[index];Output a newline if the current index +1%10 is 0. if ((index +1)%10==0)
displayLower Implementation
Create a local variable that will be used to hold the number of numbers displayed. Initialize it to 0Create a for loop that walks through each element of the array
If number is > the current array element then
display the array elementincrement the number of numbers displayed variableOutput a new line character if 10 elements have been displayed on the current line. For example: if (numDisplayed %10==0)
displayHigher implementation
The implementation of this function is exactly like the displayLower function. The only difference is the expression within the if statement that compares the number to the current array element. The if statement should be: if number is > the current array element
displayAverage implementation
Create the following local variables
int totaldouble average
Create a for loop that walks through each element of the array
Add the array element to the total
Calculate and return the average - total / size. Don't forget to cast total to double before performing the division.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!