Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to code a menu that has six options to the user. Need to be done using fu

ID: 3638788 • Letter: I

Question

I need to code a menu that has six options to the user. Need to be done using function call.

1. Initialize array using RNG. (initialize array using for loop)
2. Display numbers in array.
3. Calculate the sum of the numbers in the array.
4. Calculate the average of numbers in the array.
5. Find the largest and smallest numbers in array.
6. Exit Program.







#include <iostream>
#include <cstdlib> //rand
using namespace std;

char upcase(char);

void RandGen();
void DisplayArray();

int main()
{
char menuChoice;
bool userNotDone = true;

while (userNotDone)
{
system("cls");

cout << " Menu " ;
cout << " A. choice A ";
cout << " B. choice B ";
cout << " C. choice C ";
cout << " X. Exit ";
cout << " Enter Menu Choice ==> ";

cin >> menuChoice;

switch (upcase(menuChoice))
{
case 'A': void RandGen();
cout << "picked A " ;
system("pause");
break;
case 'B': void DisplayArray();
cout << "picked B " ;
system("pause");
break;
case 'C': //function call
cout << "picked C " ;
system("pause");
break;
case 'X': cout << "Exit ";
userNotDone = false;
break;
default: cout << "Error message " ; //function call
}
}//while end.

return 0;
}
void RandGen()
{
int seed, rg;

srand(3);

cout << "enter the seed value ==> ";
cin >> seed;

srand(seed);

for(int lcv = 0; lcv <10; lcv++)
rg = rand() % 20;
}
void DisplayArray()
{
int rg;

cout << rg << endl;
}


char upcase(char inComing)
{
if(inComing >= 'a' && inComing <= 'z')
inComing -= 32;
//inComing = inComing - 32;

return inComing;
}





Explanation / Answer

/* Pre-defined functions: toupper() - returns the upper case letters User-defined functions: void initializeArray(int[]) - initialize the array of numbers. void displayArray(int[]) - display the elements of the array. void sumOfArrayIntegers(int[]) - calculate and display the sum of numbers in the array. void averageOfArrayIntegers(int[]) - calculate and display the average of numbers in the array. void largestAndSmallestOfArrayIntegers(int[]) - find and display the largest and the smallest numbers in the array. void exitProgram() - exit the program */ #include "stdafx.h" #include #include //rand using namespace std; void initializeArray(int[]); void displayArray(int[]); void sumOfArrayIntegers(int[]); void averageOfArrayIntegers(int[]); void largestAndSmallestOfArrayIntegers(int[]); void exitProgram(); int main() { const int size = 10; // Size of the array int array[size]; bool choice = true; char menuChoice; char ch; // asking for continuity the program while(choice) { cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote