Help with columns

I am doing a input/output program for homework for one of my classes from my c++ book. Our teacher just want us to change the output into columns instead of rows.

Input File:
Andrew Miller 87.50 89 65.75 37 98.50

Here is the problem.

using namespace std;

int main()
ifstream inFile;
ofstream outFile;

double test1, test2, test3, test4, test5, average;

string firstName;
string lastName;"test.txt");"testavg.txt");

cout<<"Input failure\n";
return 1;
cout<<"Output failure\n";
return 1;

outFile<< setprecision(2);

cout<<"Processing data"<< endl;

outFile<< "Student Name: " << firstName << " "<< lastName <<endl;

inFile >> test1 >> test2 >> test3
>>test4 >>test5;

outFile<< "Test scores: "<< setw(6) << test1

average = (test1+test2+test3+test4+test5)/5.0;

outFile<< "Average Test Score: "<< setw(6)
<< average << endl;


return 0;

When I execute the program, it is in rows like this.

Output file looks like this:

Student Name Andrew Miller
Test Scores 87.50 89.00 65.75 37.00 98.50
Average Test Scores: 75.55

How do I get it to look like this:

Student Name Test Scores Avg Test Scores

Andrew Miller 87.50,89,65.75,37.00,98.50 75.55

In other words, how do I line it up to be column like instead of being in a row?

Any help would be appreciated.

Thank You
Topic archived. No new replies allowed.