0

right now im working on a program that reads a series of numbers (doubles) from the user, then prints the mean and the
range.
also:
• I do not know ahead of time how many numbers will be in the list.
• When ctrl-z if pressed, stop asking for user input
• The numbers will be in the range of 0.0 to 100.0. Ignore numbers outside of this range.

I've tried to think of a way to get the mean and range but it ends up not making sense, and i know the ctrl-z thing has to do with it being 'false' or something? any help is greatly appreciated

#include <iostream>
#include <string>

using namespace std;

int main()
{
	double input, answer;
	double total = 0;
	while (cin >> input)
	{
		if ((input > 0) && (input < 100));
			
		
		else
		{cout << "out of range; ignored." << endl;}

	}
		
		
}
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by wildgoose
0

An error..
You had a semi-colon on the if()

int main()
{
   double input, answer;
   double total = 0;
   unsigned int count = 0;

   while (cin >> input)
   {
      if ((0.0 <= input) && (input <= 100.0))
      {
// Track number of entries, and sum the running tally.
// If you need to track all of them then you'll need some kind of dynamic array!

      }
      else
      {
           cout << "out of range; ignored." << endl;}
      }
   }   // MISSING while terminator		
		

       // Calculate AVERAGE and sum!
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.