here is what I have to create: using while, for, do...while
Write a program that displays a menu with the following choices to the user.
A - Find the largest # with a known quantity of numbers
B - Find the smallest # with an unknown quantity of numbers
C - Quit
Please enter your choice ___
This menu needs to be repeatedly displayed until the user chooses to quit.
If A is chosen, you should ask the user how many numbers he wants to enter. If he enters 5, you should read 5 numbers from him. You should then display the largest number he entered. Use a for loop to read these and display the largest.
If B is chosen, you should keep reading numbers no matter what until the user enters -99. Then you should display the smallest number he entered not counting the -99.
Hint - you only need to store the largest or smallest number, not every number that is input.
This is what I got so far and I am stuck dont know what it should look like or what to do. please help..
#include <iostream>
#include <iomanip>
using namespace std;
double larger(double x, double y);
double smaller (double x, double y);
const int SENTINEL = -99;
int main()
{
double num;
double max;
char ch1;
char a, b, c, i;
char letter;
int large, small, qty;
int count;
cout << "Please choose one of the following choices.\n"
<< "A - Find the largest # with a known quantity of numbers\n"
<< "B - Find the smallest # with an unknown quantity of numbers\n"
<< "C - Quit" << endl;
cout << "Please enter your choice ";
cin >> letter;
ch1 = letter;
cout << endl;
cout << "Please enter quantity of numbers ";
cin >> qty;
count = qty;
cout << "Enter " << qty << " " << "numbers ";
cin >> num;
max = num;
for (count = 1; count < qty; count++)
{
cout << "Enter another number ";
cin >> num;
max = larger(max, num);
}
cout << "The largest number is " << max
<< endl;
return 0;
}
double larger(double x, double y)
{
if (x >= y)
return x;
else
return y;
}