***C++ ONLY***
Menu driven program
First load an array(lists) with the values 3, 4, 84, 5, 2, 47, and 7 in this order
Then sort the array(list)
Create a program with a menu, with choices 1 for factorial (single value, which everyone will use 20!), 2 for median value , 3 for average, 4 for maximum, 5 for minimum, and 6 to end the program.
Use a do loop (not while)
Python does not have a Do loop, so instead use
while True:
where for quit you can issue the break command
Use a switch statement inside the loop to make your choice of 1, 2, etc. for Java and C++ and an if/elif in Python
You also need to to include a screen shot of your menu on the screen in your submission.
To make for a better looking output, store the function (Factorial, Median, Maximum, etc.) in a string array(list) and your answer in a numeric array(list). (two arrays) Then in the exit module (choice 6) print out your answers. Note this involves running choices 1-6 in order.
***C++ ONLY***
C++ code:
#include<iostream>
#include<list>
#include<vector>
using namespace std;
void fact()
{
int n,val=1;
cout<<"Enter a number:";
cin>>n;
for(int i=2;i<=n;i++)
{
val*=i;
}
cout<<"Factorial of "<<n<<" is
"<<val<<endl;
}
int sum(list<int> list1)
{
int s=0;
for (list<int>::iterator i=list1.begin(); i!=list1.end();
i++)
s+= *i;
return(s) ;
}
int med(list<int> list1)
{
int s=0;
for (list<int>::iterator i=list1.begin(); i!=list1.end();
i++)
{
if(s==list1.size()/2)
return(*i);
s++;
}
return(s) ;
}
int main()
{
int flag=1,option;
list<int> list1;
list1.push_back(3);
list1.push_back(4);
list1.push_back(84);
list1.push_back(5);
list1.push_back(2);
list1.push_back(47);
list1.push_back(7);
list1.sort();
do
{
cout<<"Enter 1 for
factorial"<<endl;
cout<<"Enter 2 for
median"<<endl;
cout<<"Enter 3 for
average"<<endl;
cout<<"Enter 4 for
maximum"<<endl;
cout<<"Enter 5 for
minimum"<<endl;
cout<<"Enter 6 to end
program"<<endl;
cin>>option;
switch(option)
{
case 1: fact();
break;
case 2:
cout<<"Median:"<<med(list1)<<endl;break;
case
3:cout<<"Average:"<<sum(list1)/list1.size()<<endl;break;
case 4:
cout<<"Maximum item in
list:"<<list1.back()<<endl;break;
case 5:
cout<<"Minimum item in
list:"<<list1.front()<<endl;break;
case 6:
flag=0;break;
}
}while(flag);
}
Output:


***C++ ONLY*** Menu driven program First load an array(lists) with the values 3, 4, 84, 5,...
***C++ Program ONLY*** Menu driven program First load an array(lists) with the values 3, 4, 84, 5, 2, 47, and 7 in this order Then sort the array(list) Create a program with a menu, with choices 1 for factorial (single value, which everyone will use 20!), 2 for median value , 3 for average, 4 for maximum, 5 for minimum, and 6 to end the program. Use a do loop (not while) Python does not have a Do loop, so...
Write a menu driven program to demonstrate the use of array and switch. It must be written in C language . Here is the menu - Press 1 to add a number to the array. Press 2 to display the numbers entered in the array so far Press 3 to find the average of the numbers entered. Press 4 to exit. Option 1 - The user should be able to enter 20 numbers only. If all twenty numbers are entered...
Python 3.7 to be used. Just a simple design a program
that depends on its own. You should also not need to import
anything. No code outside of a function!
Median List Traversal and Exception Handling Create a menu-driven program that will accept a collection of non-negative integers from the keyboard, calculate the mean and median values and display those values on the screen. Your menu should have 6 options 50% below 50% above Add a number to the list/array...
CSC 130 Lab Assignment 8 – Program Menu Create a C source code file named lab8.c that implements the following features. Implement this program in stages using stepwise refinement to ensure that it will compile and run as you go. This makes it much easier to debug and understand. This program presents the user a menu of operations that it can perform. The choices are listed and a prompt waits for the user to select a choice by entering a...
Assignment Write a menu-driven C++ program to manage a class roster of student names that can grow and shrink dynamically. It should work something like this (user input highlighted in blue): Array size: 0, capacity: 2 MENU A Add a student D Delete a student L List all students Q Quit ...your choice: a[ENTER] Enter the student name to add: Jonas-Gunnar Iversen[ENTER] Array size: 1, capacity: 2 MENU A Add a student D Delete a student L List all students...
Write a menu-driven C++ program to manage a class roster of student names that can grow and shrink dynamically. It should work something like this (user input highlighted in blue): Array size: 0, capacity: 2 MENU A Add a student D Delete a student L List all students Q Quit ...your choice: a[ENTER] Enter the student name to add: Jonas-Gunnar Iversen[ENTER] Array size: 1, capacity: 2 MENU A Add a student D Delete a student L List all students Q...
Objectives: Integer arithmetic, Functions, menus. Write a C++ program that displays the following menu of choices. 1. Find the number of digits in an integer. 2. Find the nth digit in an integer. 3. Find the sum of all digits of an integer. 4. Is the integer a palindrome? 5. Quit Enter a choice: Page 1 of 4 For each of the choices (1, 3, 4), Read a positive integer number and call a function that processes the menu choice...
Develop a system flowchart and then write a menu-driven C++ program that uses user-defined functions arrays, and a random number generator. Upon program execution, the screen will be cleared and the menu shown below will appear at the top of the screen and centered. The menu items are explained below. Help Smallest Quit H or h ( for Help ) option will invoke a function named help() which will display a help screen. The help screen(s) should guide the user...
Write a C++ program to run a menu-driven program with the following choices: Count number of even digits in a number Compute the factorial of a number Quit Make sure your program conforms to the following requirements: 1. This program should be called playingWithNumbers.cpp 2. Write a function called getValidUserInputPosNumGT0 that allows a user to enter an integer and validated that the number is > 0. It must have a pass by reference parameter that will store the value selected...