Write a program that will ask the user for a set of ten numbers. After all ten numbers have been entered, the program will display the largest and smallest numbers of the data set. The program will then prompt the user whether he/she would like to enter another set of data. When the user indicates he/she is finished entering data sets, the program will finally display the average largest number and the average smallest number for all sets entered.
When pasting code, please use the code tags. In the format box they show up as <>. Just put your code between the tags that show up.
You didn't ask a question. What do you want us to help you with?
Also, there is no reason to disregard your comments. Other than one being after what it describes rather than before, I think they are good comments for a beginning programmer.
Im sorry about pasting the wrong way. This is my first time asking for professional help.
My logic just wont work with this project. Am I doing this right? My plan was to start off with whatever the 1st number was and if the 2nd number is lower, ill name it low, if the 3rd number is even lower, ill replace low with the 3rd number. If it is higher than the 2nd and the 1st number, ill name it high.
1. Read in number
2. Set low <- number
3. Set high <- number
4. Loop 9 times
a. Read in number
b. If number < low : set low <- number
c. Else If number > high : set high <- number
//Get input
cout << "Enter number: ";
cin >> starter;
low = starter; /// assume first value is lowest
high = starter; /// assume first value is highest
for (count = 1; count <= 9; count ++)
{
cout << "Enter number: ";
cin >> input;
if (input < low) /// compare input against lowest value and not starter which is first value
low = input;
if (input > high) ///
high = input;
}
int total_min, total_max;
int count;
char c;
total_min = total_max = 0;
count = 0;
do
{
constint LENGTH = 10;
bool empty = true;
int min. max;
cout << "Enter a sequence of " << LENGTH << " integer numbers\n";
for ( int i = 0; i < LENGTH; i++ )
{
int number;
cout << "number " << i + 1 << ": ";
cin >> number;
if ( empty )
{
min = max = number;
empty = false;
}
else
{
if ( number < min ) min = number;
if ( max < number ) max = number;
}
}
total_min += min;
total_max += max;
++count;
cout << "Minimum value is " << min
<< ", and maximum value is " << max
<< end;
cout << "Continue (y/n)? "
cin >> c;
} while ( c == 'y' || c == 'Y' );
cout << The average minimum is " << total_min / count
<< ", and the average maximum is " << total_max / count
<< endl;
Thank you Everyone!!!!! I used vlad from moscow's code since it is more complete.
However, when displaying "min", if i put a float, it shows a weird number. When I put 1.5 for the lowest, it displays "The lowest number is 5.98839e-039."
Why? How do I fix it? Here is my modified code. Oh, and how important is the
if ( empty ) block?