I need the program to have 3 options. Choose how many #'s to enter, and display the largest # input; enter #'s until -99 is input then end program and display smallest # entered; or quit the program. I have a large part of the program written but it's not working properly and I am pretty new to programming. Can someone just help me get the code for the first part straightened out then maybe I can figure it out from there. Here is what I have:
#include
using namespace std;
const int SENTINEL = -99; //to end option 'B'
int number; //variable to store #s
int counter;
char limit; //variable to store amount of #s to input in 'A'
int main()
{char sel;
number = 0;
int count = 0;
do{
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)
{case 'A':
case 'a':
cout << "Enter the amount of numbers to input in series: ";
2006-11-12
08:36:48
·
2 answers
·
asked by
lparker_2005
2
in
Computers & Internet
➔ Programming & Design
here's the rest of it
cin >> limit;
while (count <= 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;
}
}
while (sel != 'c' || sel != 'C');
return 0;
}
Thanks for any help!!
2006-11-12
08:38:36 ·
update #1
A couple of the problems I have with this program is in option A when I enter the amount of numbers I want to include it starts the count as 0 instead of 1. It also doesn't stop when I reach the number I entered. I am not sure how to correct this.
2006-11-12
08:42:54 ·
update #2