So here is what I am trying to accomplish. I have been trying and trying for a few hours to figure out how to do this.
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.
#include <iostream>
using namespace std;
const int A_QUANTITY = 10; // Amount of #'s entered for option A
const int B_SENTINEL = -99; // Sentinal used to end option B
int main ()
{
bool again = true; // Used to control main source loop
char choice; // Stores the choice made
int biggest; // Stores largest #
int smallest; // Stores smallest #
int temp; // Stores next number for comparison
int i; // Controls the For loop
while (again)
{
// Displays instructions to user
cout << "A - Find the largest # with a known quantity of numbers" << endl;
cout << "B - Find the smallest # with an unknown quantity of numbers" << endl;
cout << "C - Exit" << endl;
cout << "Please enter your choice" << endl;
// Gets input from user
cin >> choice;
if (choice == B) // Beginning of if statement
{
i = 0;
do
{
cout << "Enter number (-99 to end): ";
cin >> i >> endl;
i++;
cout << "You entered: " << i << "\i";
}while (i != 0);
}
else if (choice == A) // Beginning of else if statement
{
for( i = 0; i < 10; i++)
cout << "i = " << i << endl;
for(i = 10; i>=0; i--);
}
{return 0;
}