For my class we have to create a program that can computer numeric grades for a course. The grades are in a file that will be the input file. Input file follows the following format: Each line contains a students last name, one space, followed by the students last name, then one space, then 10 quiz scores all on one line, each are whole numbers separated by one space. The program should place date from the input file and put it in the output file with the exact format except there will be an additional number (of type double) at the end of each line. The number will be the average of the ten quizzes.
At this point, I have got my program to grab the first and last name, of the first line, however I am not sure how I can then stream the quiz scores after the name check. I also then still need to place an 11th number on the output file that will act as the average of the previous 10 per line.
http://i.stack.imgur.com/vYRSZ.png
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <fstream>
using namespace std;
int main()
{
ifstream in_stream;
ofstream out_stream;
char name;
int num_spaces, scores, total_scores;
in_stream.open("scores.txt");
if (in_stream.fail())
{
cout << "Input file opening failed.\n";
exit(1);
}
out_stream.open("Output.dat");
if (out_stream.fail())
{
cout << "Output file opening failed.\n";
exit(2);
}
num_spaces = 0;
while (num_spaces < 2)
{
cout << "in first while loop";
//in_stream >> name;
//out_stream << name;
in_stream.get(name);
out_stream.put(name);
if (name == ' ')
{
num_spaces++;
}
}
/*if (num_spaces > 2)
{
total_scores = 0;
in_stream >> scores;
total_scores += scores;
out_stream << scores;
}
*/
in_stream.close();
out_stream.close();
return 0;
}