#include <fstream> 
#include <iostream> 
using namespace std; 
  
int main() 
{ 
  // open 8Scores.txt for input 
  ifstream fin; 
  fin.open("8Scores.txt"); 
  if (!fin.good()) throw "I/O error"; 
  
  // read the scores and build the sum 
  int scoreTotal = 0; 
  int i; // loop counter 
  for (i = 0; i < 8; i++) 
  { 
    int aScore; 
    fin >> aScore; 
    fin.ignore(1000, 10); 
    scoreTotal += aScore; 
  } // for 
  fin.close(); 
  
  // calculate and output the average 
  double average = scoreTotal / 8.0; 
  cout << "The average of 8 numbers is " 
    << average << endl; 
} // main 
