0

I have to take my current code which displays a menu and repeats until the option 'c' is chosen which quits the program. Now I have to modify that same code to include a function for both A and B. The function for A should have the quantity of numbers passed in as a parameter and needs to return the largest number. The function for B should have no parameters and return the smallest number. I need to use void greatest() {

the example is

```
void greatest()
{
//Initialize final result variable to largest number possible
//Ask user How many numbers he would like to enter
//Read number of numbers user plans to enter
//start a loop, increment from 0 to number of numbers user plans to enter
//Read next number
//Compare number to final result variable
//if number is greater than final result variable, then
//store in final result variable
//end of loop
}
```

Here is my working code and what I need to modify I don't know what to leave in the main body and move to the void body and what exactly the first comment in the example means to do someone please help me!!

```
#include <iostream>
using namespace std;
double larger(double x, double y);
double smaller(double x, double y);
const int SENTINEL = -99;
int main()
{
bool done;
char letter;
char a, b, c;
int qty, count;
double max, low, num;
done = false;
while (!done)
{
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;
cout << endl;
if (letter == 'a')
{
cout << "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);
done = false;
}
cout << "The largest number is: " << max << endl;
done = false;
}
if (letter == 'b')
{
cout << "Enter a number, to stop enter -99: ";
cin >> num;
low = num;
while (num != SENTINEL)
{
cout << "Enter a number, to stop enter -99: ";
cin >> num;
if (num != SENTINEL)
{
low = smaller(low, num);
}
}
cout << "The smallest number is: " << low << endl;
done = false;
}
if (letter == 'c')
{
done = true;
}
}
return 0;
}
double larger (double x, double y)
{
if (x >= y)
return x;
else
return y;
}
double smaller (double x, double y)
{
if (x <= y)
return x;
else
return y;
}
```