Code
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main ()
{
ifstream inputFile; //inputFile object to be attached
string userFile; //File to be opened is stored in this string
int totalValue = 0, //Accumulator for the values read
evenCount = 0, //Used to count amount of even numbers
oddCount = 0, //Used to count amount of odd numbers
dataRead; //Stores the value read of the opened file
//Prompts for file name to open
cout << "Enter the file name you wish to open: ";
cin >> userFile;
//Attempts to open file
inputFile.open(userFile.c_str());
//Will run if the file has opened
if(inputFile)
{
//Will run if data has been read
while(inputFile >> dataRead)
{
//Test if it is even, if so add a count to the evenCount
if(dataRead % 2 == 0)
{
evenCount++;
}
//If it isn't even, then add a count to the oddCount
else
{
oddCount++;
}
//Displays the current value read
cout << "Value read was: " << dataRead << endl;
//Accumulates the values read
totalValue += dataRead;
}
//Displays the following values
cout << "Total Value: " << totalValue << endl
<< "Amount of Odd: " << oddCount << endl
<< "Amount of Even: " << evenCount << endl
<< "Program Complete. " << endl;
}
//Error message if the file was unable to open
else
{
cout << "Program Failed. " << endl;
}
return 0;
}
Use code braces when posting your code!

If you need help post here or send me a PM.
Book to read: C++ Early Objects
Last years PDF:
http://eembdersler.files.***/2011/07/c_early.pdfI recommend buying the most recent version hard copy. It comes with answers to checkpoints and what not.
This post was edited by cssa on Oct 14 2013 01:18am