#include <iostream>
#include <string>
#include <fstream>
#include <vector>

using namespace std;

int main ()
{
	vector<double> inputs;
	string inputFile = "test.txt";
	double temp;
	double adds = 0;
	ifstream fileIn;

	fileIn.open(inputFile.c_str());

	if (fileIn.fail())
	{
		cerr << "Cannot open file" << endl;
	}

	while (!fileIn.eof())
	{
		fileIn >> temp;
		// if the input is not double, get out of the loop
		if (fileIn.fail())
			break;
		// record the input
		inputs.push_back(temp);
		adds = adds + temp;
	}
	fileIn.close();

	cout << "total: " << adds << endl;
	cout << "results:" << endl;

	for (int i = 0; i < (int)inputs.size(); i++)
		cout << inputs[i] << endl;
	
	return 0;
}