#include <iostream>
#include <cstdlib>
#include <vector>
using std::cin;
using std::cout;
int main()
{
std::vector<float> fltVector;
std::string input("x");
cout << "Usage: \n\tKeep entering a number, this includes decimals, when you have entered all the numbers, type an \"x\"\n\n(c) Copyright X-Istence.com\n\n";
// We run the while loop forever
while (1)
{
// Get our first input.
cout << "Please enter a number: ";
cin >> input;
// If the input is empty, we end this loop, and go on to the rest of the program
if (input == "x" || input == "X")
break;
// Add the number to the float vector.
fltVector.push_back(atof(input.c_str()));
}
// User decided they have inputted enough info
// We need an iterator to be able to go over the entire vector
std::vector<float>::iterator iter;
// Create another float to contain the total, so we can get the mean out of it.
// I have no clue what variance/deviation is, so ill just keep it to the mean.
float total = 0;
for (iter = fltVector.begin(); iter != fltVector.end(); iter++)
// Add the amount that the vector has to total.
total += *iter;
// A bit of output can not hurt us
cout << "\n\n\nYou have entered " << fltVector.size() << " items.";
cout << "\n\nThe mean of the numbers you have entered is " << total / fltVector.size() << "\n";
return 0;
}