Thursday, July 9, 2009

Help With My C++ Program PLEASE?

This is what I have now and I have 2 have to write a program the reads students grades together with their test grades. It suppose to compute the average test scores an then assign the appropriate grade. have to use a void function to determine the average for the five test scores and a value returning function to determine and return each students grade. the students grades are on an infile and i have to output it to an outfile.

















#include %26lt;iostream%26gt;


#include %26lt;fstream%26gt;





using namespace std;








calculateGrade (float,average);





int main ()


{


ifstream infile;


infile.open("C:\inGrade.dat");

















outfile %26lt;%26lt; calculateGrade%26lt;%26lt; endl;








ofstream outfile;


outfile.open("C:\FinalGrades.txt");














infile.close ();


outfile.close ();








system("pause");


return 0;





char calculateGrade (float average)


{


char grade;





if (average %26gt;= 80.0)


grade = 'A';


else if (average %26gt;= 70.0)


grade = 'B';


else if (average %26gt;= 60.0)


grade = 'C';


else if (average %26gt;= 50.0)


grade = 'D';


else


grade = 'F';


return (grade);


}




















}

Help With My C++ Program PLEASE?
In your function prototype line, you need to define the return type, or you will get an error saying that two functions differ only in their return type. Also you have a comma between void and average. Get rid of it.





Also, when you call calculateGrade, you need to pass the argument.





I am not going to finish the program for you, but this should be enough to help you make some progress.
Reply:Why is calculateGrade inside main? Also you're using outfile before defining it.





"outfile %26lt;%26lt; calculateGrade%26lt;%26lt; endl;








ofstream outfile;


outfile.open("C:\FinalGrades.t... "





When calling calculateGrade() you're not using the correct syntax or arguments..





"outfile %26lt;%26lt; calculateGrade%26lt;%26lt; endl;"





When declaring calculateGrade you have a comma after the type 'float'





"calculateGrade (float,average);"





I recommend you pay more attention to the compiler error output as it will probably tell you most of that.
Reply:Ok, what exactly did you need help with in this program?


No comments:

Post a Comment