my file wont output into a .txt file

//IT 210 Business Applications with C++
//Programmer:
//November 9, 2010
//Program Assignment 3: Student Grades III

//Preprocessor directives
#include <fstream>
#include <iostream>
#include <iomanip>
using namespace std;

//global constants, global variables, function prototypes
void headerfn();
float progavgfn(int prog1, int prog2, int prog3);
float testavgfn(int test1, int test2, int test3);
float courseavgfn (float progavg, float testavg);
string gradefn (float courseavg);
void namefn(string &fname, string &lname);
void scoresfn(int &prog1, int &prog2, int &prog3, int &test1, int &test2, int &test3);
int totalfn(int prog1, int prog2, int prog3, int test1, int test2, int test3);
void outputfn(string firstname, string lastname, int total, float progavg, float testavg, float courseavg, string grade);
void outputtextfn(string firstname, string lastname, int total, float progavg, float testavg, float courseavg, string grade);

int main (){
ofstream fout;
fout.open("test.txt");
system ("color f0");
headerfn();
string firstname, lastname;
namefn(firstname, lastname);
int program1, program2, program3;
int test1, test2, test3;
scoresfn(program1, program2, program3, test1, test2, test3);

cout<<setw(70)<<setfill('=')<<" "<<endl;
cout<<setw(20)<<setfill(' ')<<"Student Name"<<setw(10)<<"Total"
<<setw(10)<<"Program"<<setw(10)<<"Test"<<setw(10)<<"Course"<<setw(10)
<<"Grade"<<endl;
cout<<setw(20)<<setfill(' ')<<" "<<setw(10)<<"Points"<<setw(10)<<"Average"
<<setw(10)<<"Average"<<endl;
cout<<setw(70)<<setfill('-')<<" "<<endl;

int total;
total=totalfn(program1, program2, program3, test1, test2, test3);
total=program1+program2+program3+test1+test2+test3;
float progavg, testavg, courseavg;
float totalprog;
totalprog=program1+program2+program3;



progavg=progavgfn(program1, program2, program3);
progavg=(total/3);


float totaltest;
totaltest=test1+test2+test3;
testavg=testavgfn(test1, test2, test3);
testavg=(totaltest/3);


courseavg=courseavgfn(progavg, testavg);
courseavg=(progavg+testavg/2);


string grade;
grade=gradefn(courseavg);


outputfn(firstname, lastname, total, progavg, testavg, courseavg, grade);

system("Pause");
return 0;
}//end of main


//*****************************************************************************
void headerfn(){
cout<<"012345678901234567890123456789012345678901234567890123456789"<<endl;
cout<<"************************************************************"<<endl;
cout<<"* IT210 Business Applications with C++ *"<<endl;
cout<<"* Programmer: *"<<endl;
cout<<"* Date: November 9, 2010 *"<<endl;
cout<<"* *"<<endl;
cout<<"* Program Assignment 3: Student Grades III *"<<endl;
cout<<"* *"<<endl;
cout<<"* This program uses functions to read student *"<<endl;
cout<<"* information from the keyboard and outputs *"<<endl;
cout<<"* the results to the monitor and a text file *"<<endl;
cout<<"* *"<<endl;
cout<<"************************************************************"<<endl;
cout<<endl;
cout<<"Welcome to the IT210 Grade Calculator!"<<endl;
return;
}//end of headerfn
//*****************************************************************************
void namefn(string &fname, string &lname){
cout<<"Please enter your first and last name: ";
cin>>fname>>lname;
}//end of namefn
//*****************************************************************************
void scoresfn(int &prog1, int &prog2, int &prog3, int &test1, int &test2, int &test3){
cout<<"Please enter first program score: ";
cin>>prog1;
cout<<"Please enter second program score: ";
cin>>prog2;
while (prog2<0||prog2>100){
cout<<"This score is out of range! Please enter a score between 0-100: ";
cin>>prog2;
}
cout<<"Please enter the third program score: ";
cin>>prog3;
cout<<"Please enter the first test score: ";
cin>>test1;
cout<<"Please enter the second test score: ";
cin>>test2;
cout<<"Please enter the third test score: ";
cin>>test3;
while (test3<0||test3>100){
cout<<"This score is out of range! Please enter a score between 0-100: ";
cin>>test3;
}
cout<<"1234567890123456789012345678901234567890123456789012345678901234567890"<<endl;
}//end of scoresfn
//******************************************************************************
int totalfn(int prog1, int prog2, int prog3, int test1, int test2, int test3){
return prog1+prog2+prog3+test1+test2+test3;
}//end of totalfn
//******************************************************************************
float progavgfn(int prog1, int prog2, int prog3){
return (prog1+prog2+prog3)/3;
}//end of progavgfn
//******************************************************************************
float testavgfn(int test1, int test2, int test3){
return (test1+test2+test3)/3;
}//end of testavgfn
//******************************************************************************
float courseavgfn(float testavg, float progavg){
return (progavg+testavg)/2;
}//end of courseavgfn
//******************************************************************************
string gradefn(float courseavg){
string grade;
if (courseavg>=90){
grade='A';
}
else if (courseavg>=80){
grade='B';
}
else if (courseavg>=70){
grade='C';
}
else if (courseavg<70){
grade='F';
}
return grade;
}//end of gradefn
//******************************************************************************
void outputfn(string firstname, string lastname, int total, float progavg,
float testavg, float courseavg, string grade){

cout<<setw(20)<<left<<setfill(' ')<<firstname+ " " +lastname<<setw(10)<<left
<<total<<setw(10)<<fixed<<showpoint<<setprecision(2)<<progavg<<setw(10)
<<fixed<<showpoint<<setprecision(2)<<testavg<<setw(10)<<fixed<<showpoint
<<setprecision(2)<<courseavg<<setw(10)<<left<<grade<<endl;

}//end of output fn
//******************************************************************************
void outputtextfn(string firstname, string lastname, int total, float progavg,
float testavg, float courseavg, string grade){
ofstream fout;
fout.open("test.txt");
fout<<setw(20)<<left<<setfill(' ')<<firstname+ " " +lastname<<setw(10)<<left
<<total<<setw(10)<<fixed<<showpoint<<setprecision(2)<<progavg<<setw(10)
<<fixed<<showpoint<<setprecision(2)<<testavg<<setw(10)<<fixed<<showpoint
<<setprecision(2)<<courseavg<<setw(10)<<left<<grade<<endl;

cout<<"output failure\n";
system("pause");
//return 1 ;



fout.close();
}}<-- this line is highlightd
when i try to run it it says 185 E:\Visual Studio 2010Projects\project3 correct1.cpp expected declaration before '}' token
Please put your code inside code tags so that we can better locate the error.
You never write to the file.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
//IT 210 Business Applications with C++
//Programmer: 
//November 9, 2010
//Program Assignment 3: Student Grades III

//Preprocessor directives
#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

//global constants, global variables, function prototypes
void headerfn();
float progavgfn(int prog1, int prog2, int prog3);
float testavgfn(int test1, int test2, int test3);
float courseavgfn (float progavg, float testavg);
string gradefn (float courseavg);
void namefn(string &fname, string &lname);
void scoresfn(int &prog1, int &prog2, int &prog3, int &test1, int &test2, int &test3);
int totalfn(int prog1, int prog2, int prog3, int test1, int test2, int test3);
void outputfn(string firstname, string lastname, int total, float progavg, float testavg, float courseavg, string grade);
void outputtextfn(string firstname, string lastname, int total, float progavg, float testavg, float courseavg, string grade);

int main (){
	ofstream fout;
	fout.open("test.txt");
	system ("color f0");
	headerfn();
	string firstname, lastname;
	namefn(firstname, lastname);
	int program1, program2, program3; 
	int test1, test2, test3; 
	scoresfn(program1, program2, program3, test1, test2, test3);

	cout<<setw(70)<<setfill('=')<<" "<<endl;
	cout<<setw(20)<<setfill(' ')<<"Student Name"<<setw(10)<<"Total"
		<<setw(10)<<"Program"<<setw(10)<<"Test"<<setw(10)<<"Course"<<setw(10)
		<<"Grade"<<endl;
	cout<<setw(20)<<setfill(' ')<<" "<<setw(10)<<"Points"<<setw(10)<<"Average"
		<<setw(10)<<"Average"<<endl;
	cout<<setw(70)<<setfill('-')<<" "<<endl;

	int total;
	total=totalfn(program1, program2, program3, test1, test2, test3);
	total=program1+program2+program3+test1+test2+test3;
	float progavg, testavg, courseavg;
	float totalprog;
	totalprog=program1+program2+program3; //warning due to conversion



	progavg=progavgfn(program1, program2, program3);
	progavg=(total/3); //warning due to conversion


	float totaltest;
	totaltest=test1+test2+test3; //warning due to conversion
	testavg=testavgfn(test1, test2, test3);
	testavg=(totaltest/3);


	courseavg=courseavgfn(progavg, testavg);
	courseavg=(progavg+testavg/2);


	string grade;
	grade=gradefn(courseavg);


	outputfn(firstname, lastname, total, progavg, testavg, courseavg, grade);

	system("Pause");
	return 0;
}//end of main


//*****************************************************************************
void headerfn(){
	cout<<"012345678901234567890123456789012345678901234567890123456789"<<endl;
	cout<<"************************************************************"<<endl;
	cout<<"* IT210 Business Applications with C++ *"<<endl;
	cout<<"* Programmer: *"<<endl;
	cout<<"* Date: November 9, 2010 *"<<endl;
	cout<<"* *"<<endl;
	cout<<"* Program Assignment 3: Student Grades III *"<<endl;
	cout<<"* *"<<endl;
	cout<<"* This program uses functions to read student *"<<endl;
	cout<<"* information from the keyboard and outputs *"<<endl;
	cout<<"* the results to the monitor and a text file *"<<endl;
	cout<<"* *"<<endl;
	cout<<"************************************************************"<<endl;
	cout<<endl;
	cout<<"Welcome to the IT210 Grade Calculator!"<<endl;
	return;
}//end of headerfn
//*****************************************************************************
void namefn(string &fname, string &lname){
	cout<<"Please enter your first and last name: ";
	cin>>fname>>lname;
}//end of namefn 
//*****************************************************************************
void scoresfn(int &prog1, int &prog2, int &prog3, int &test1, int &test2, int &test3){
	cout<<"Please enter first program score: ";
	cin>>prog1;
	cout<<"Please enter second program score: ";
	cin>>prog2;
	while (prog2<0||prog2>100){
		cout<<"This score is out of range! Please enter a score between 0-100: ";
		cin>>prog2;
	}
	cout<<"Please enter the third program score: ";
	cin>>prog3;
	cout<<"Please enter the first test score: ";
	cin>>test1;
	cout<<"Please enter the second test score: ";
	cin>>test2;
	cout<<"Please enter the third test score: ";
	cin>>test3;
	while (test3<0||test3>100){
		cout<<"This score is out of range! Please enter a score between 0-100: ";
		cin>>test3;
	}
	cout<<"1234567890123456789012345678901234567890123456789012345678901234567890"<<endl;
}//end of scoresfn
//******************************************************************************
int totalfn(int prog1, int prog2, int prog3, int test1, int test2, int test3){
	return prog1+prog2+prog3+test1+test2+test3;
}//end of totalfn
//******************************************************************************
float progavgfn(int prog1, int prog2, int prog3){
	return (prog1+prog2+prog3)/3; //warning due to conversion
}//end of progavgfn
//******************************************************************************
float testavgfn(int test1, int test2, int test3){
	return (test1+test2+test3)/3; ////warning due to conversion
}//end of testavgfn
//******************************************************************************
float courseavgfn(float testavg, float progavg){
	return (progavg+testavg)/2;
}//end of courseavgfn
//******************************************************************************
string gradefn(float courseavg){
	string grade;
	if (courseavg>=90){
		grade='A';
	}
	else if (courseavg>=80){
		grade='B';
	}
	else if (courseavg>=70){
		grade='C';
	}
	else if (courseavg<70){
		grade='F';
	}
	return grade;
}//end of gradefn
//******************************************************************************
void outputfn(string firstname, string lastname, int total, float progavg, 
							float testavg, float courseavg, string grade){

								cout<<setw(20)<<left<<setfill(' ')<<firstname+ " " +lastname<<setw(10)<<left
									<<total<<setw(10)<<fixed<<showpoint<<setprecision(2)<<progavg<<setw(10)
									<<fixed<<showpoint<<setprecision(2)<<testavg<<setw(10)<<fixed<<showpoint
									<<setprecision(2)<<courseavg<<setw(10)<<left<<grade<<endl;

}//end of output fn
//******************************************************************************
void outputtextfn(string firstname, string lastname, int total, float progavg, 
									float testavg, float courseavg, string grade)
{
	ofstream fout;
	fout.open("test.txt");
	fout<<setw(20)<<left<<setfill(' ')<<firstname+ " " +lastname<<setw(10)<<left
		<<total<<setw(10)<<fixed<<showpoint<<setprecision(2)<<progavg<<setw(10)
		<<fixed<<showpoint<<setprecision(2)<<testavg<<setw(10)<<fixed<<showpoint
		<<setprecision(2)<<courseavg<<setw(10)<<left<<grade<<endl;
	cout<<"output failure\n";
	system("pause"); 
	//return 1 ;
	fout.close();
}


This will compile. You have some warnings in your code. And some other possible mistakes. You can start from here.
Topic archived. No new replies allowed.