1. ## Help Help Help!!!

I have a problem i can't seem to solve
Combining While Loops and If Statements
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.

this is my prompt so far. The average is only the last number not all the cins combine between 0 and 100

Code:
```#include <iostream>
#include <string>

using namespace std;

int main ()
{
double n, sum = 0, count = 0;

while(cin >> n)
{cin >> n;
if  ((n >= 0.0) && (n <= 100.0))
{
++count;
sum += n;
}

else if (n == '^Z') break;

else
{
cout << "out of range: ignored.\n";
}
}

cout << "The average is " << sum / count << endl;

}```

2. You've got too many read statements. (Edit: That is to say, you've got a read statement in your while condition, plus one at the top of the loop.)

3. how do i fix this then?

4. Remove the extra read statements?

5. which ones are the extra read statment

6. Originally Posted by Woot
which ones are the extra read statment
So, trace through your program by hand. Take a list of numbers as input, say "1 47 36 29 86 55 ^Z" and see what happens as your program executes.

7. Do you know what your read statements are? I somehow come to the conclusion that you haven't been paying attention in class. :P

8. The question is do you know which one is in the expression and which one is not?
Which one are you using to terminate the loop and which one is not used to terminate the loop?

9. This is wrong:
Code:
`else if (n == '^Z') break;`
The purpose of the instruction to "enter control‐Z" is to simulate end of file, and when end of file is encountered, (cin >> n) evaluates to false, terminating the loop.

10. FYI, from the forum guidelines:
Tips for Efficient and Successful Posting

1. Don't use all caps.

2. Use descriptive subject lines. Do not put URGENT!, or NEED HELP NOW, etc. in your title; it will not make people look at it any faster. Doing this makes many old time helpers on this board not look at the post at all.
Help Help Help!!! does not qualify as a descriptive subject line.

11. can you delete a board post?

12. We generally don't delete posts because they can be useful for future readers. We'll usually delete inappropriate comments, though.