1

Hi again and thanks for the help!

PROBLEM: Only every other number entered by the user is registered by my program, except the last number, which is always registered. **How can I get the program to register every line? And what is causing it to skip an input line in the first place?**

I can't explain it, and I've tried a number of things from moving around where the cin>>x; input is located to using cin.ignore() ; and getlines. It hasn't worked.

```
/*Write a program that reads a series of numbers (doubles) from the user,
then prints the mean and the range.
Notes:
• You do not know ahead of time how many numbers will be in the list.
• When you want to stop entering numbers, enter control+Z
• The range is the difference between the lowest and the highest number.
• The numbers will be in the range of 0.0 to 100.0. Ignore any numbers outside of this range.*/
#include <iostream>
using namespace std;
int main ()
{
double x;
double max=0.0;
double min=100.0;
double count = 0.0;
double sum = 0.0;
while(cin>>x)
{
cin>>x;
if (x>=0.0 && x<= 100.0)
{
if(x>max)
{
max=x;
}
if (x<min)
{
min=x;
}
count++;
sum = x + sum;
}
else
{
cout<<"out of range; ignored."<<endl;
}
}
cout<<"max= "<<max<<endl;
cout<<"min= "<<min<<endl;
cout<<"count= "<<count<<endl;
cout<<"sum= "<<sum<<endl;
double avg = (sum)/count;
double range = max - min;
cout<<"The average is "<<avg<<endl;
cout<<"The range is "<<range<<endl;
}
```