You need to write a menu driven program . The program allows a user to enter five numbers and then asks the user to select a choice from a menu. The menu should offer the following four options – 1....

1 answer below »

You need to write a
menu driven program.
The program allows a user to enter five numbers and then asks the user to select a choice from a menu. The menu should offer the following four options –




1. Display the smallest number entered
2. Display the largest number entered
3. Display the sum of the five numbers entered

4. Display the average of the five numbers entered




You must use a "switch" statement in your code to determine what action to take. Provide an error message if an invalid choice is entered.


Run the program five times, once using each option and once with an invalid option. Each run is to use the following set of data:
18, 21, 17, 44, 9.




Submit a Word file with IPO (10 points), source code (80 points) and the screenshots of the results of the five program runs (10 points).


Answered Same DayApr 02, 2021

Answer To: You need to write a menu driven program . The program allows a user to enter five numbers and then...

Arun Shankar answered on Apr 03 2021
154 Votes
Numbers program/program.cpp
#include
using namespace std;
int main()
{
int a,b,c,d
,e;
cout<<"Enter five numbers : ";
cin>>a>>b>>c>>d>>e;
cout<<"\nMENU\n--------------";
cout<<"\n1. Largest number";
cout<<"\n2. Smallest number";
cout<<"\n3. Sum of numbers";
cout<<"\n4. Average of numbers";
cout<<"\n5. Quit";
int input;
cout<<"\nEnter your choice [1-5]: ";
cin>>input;
double sum = a+b+c+d+e;
double avg = sum/5.0;
switch(input)
{
case 1:
{
if((a>=b) && (a>=c) && (a>=d) && (a>=e))
cout<<"Largest = "< else if((b>=a) && (b>=c) && (b>=d) && (b>=e))
cout<<"Largest = "< else if((c>=a) && (c>=b) && (c>=d) && (c>=e))
cout<<"Largest = "< else if((d>=a) && (d>=b) && (d>=c) && (d>=e))
cout<<"Largest = "< else
cout<<"Largest = "< break;
}
case 2:
{
if((a<=b) && (a<=c) &&...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here