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;
	
	
}