I have been taking a programming course for a few weeks now and need a little help with an assignment. My assignment is to write a program that displays a menu with the the option to find the largest # with a known quantity of numbers; find the smallest # with an unknown quantity of numbers or quit.
Here is what I have so far, but my book has gotten me so confused. I need some pointers as to what I am missing or what is wrong and needs fixed. Any help would be greatly appreciated.
Serious answers only please.
#include
using namespace std;
const int SENTINEL = -99; //to end option 'B'
int number; //variable to store numbers
int counter;
char limit; //variable to store amount of numbers to input in 'A'
int main()
{
char sel;
number = 0;
int count = 0;
cout << "A) Find the largest # in a list." << endl;
cout << "B) Find the smallest # in a list." << endl;
cout << "C) Quit." << endl;
cout << "What do you want to do?" << endl;
cin >> sel;
switch (sel)
2006-11-11
06:25:17
·
5 answers
·
asked by
lparker_2005
2
in
Computers & Internet
➔ Programming & Design
{
case 'A':
case 'a':
cout << "Enter the amount of numbers to input in series: ";
cin >> limit;
while (counter < limit)
{
cout << "Enter the " << count << " number: ";
count++;
cin >> number;
}
break;
case 'B':
case 'b':
while (number != SENTINEL)
{
cout << "Enter as many numbers as you like. When you are finished enter "
<< SENTINEL << "." << endl;
cin >> count >> number;
}
break;
case 'C':
case 'c':
break;
default:
cout << "Invalid Input." << endl;
break;
}
return 0;
}
2006-11-11
06:27:02 ·
update #1
We haven't learned about arrays yet. Just basic loop structures.
2006-11-11
07:04:46 ·
update #2