Please help me figure out what is wrong with my code...
#include <iostream> // required to perform C++ stream I/O
#include <iomanip> // required for parameterized stream manipulators
using namespace std; // for accessing C++ Standard Library members
//declaration of calculateAverage function-template prototype
template <class T>
T calculateAverage(T dataValue[], int size)
// function main begins program execution
;int main()
{
int classSize; // size of the class
// prompt the user for and input class size
cout << "\nEnter the number of students in the class: ";
cin >> classSize;
// determine whether the user input a valid value
while ( classSize <= 0 )
{
cout << "\nError: Please enter a positive value" << endl;
// prompt the user for and input class size
cout << "\nEnter the number of students in the class: ";
cin >> classSize;
} // end while
// dynamically allocate memory for the tests array
int *tests = new int[ classSize ];
// dynamically allocate memory for the GPA's array
double *GPAs = new double[ classSize ];
for ( int count = 0; count < classSize; count++ )
{
// prompt the user for and input the standardized test scores
cout << "\nEnter student #" << count + 1 << "'s standardized "
<< "test score (0 - 1600): ";
cin >> tests[ count ];
// determine whether the user entered valid input
while ( tests[ count ] < 0 || tests[ count ] > 1600 )
{
cout << "\nError: Please enter a value between 0 and 1600"
<< endl;
// prompt the user for and input the standardized test score
cout << "\nEnter student #" << count + 1 << "'s "
<< "standardized test score (0 - 1600): ";
cin >> tests[ count ];
} // end while
// prompt the user for and input the student's GPA
cout << "Enter student #" << count + 1 << "'s GPA "
<< "(0.0 - 4.0): ";
cin >> GPAs[ count ];
// determine whether the user entered valid input
while ( GPAs[ count ] < 0.0 || GPAs[ count ] > 4.0 )
{
cout << "\nError: Please enter a value between 0.0 and 4.0"
<< endl;
// prompt the user for and input the student's GPA
cout << "\nEnter student #" << count + 1 << "'s GPA "
<< "(0.0 - 4.0): ";
cin >> GPAs[ count ];
} // end while
} // end for
// calculate and display the standardized test and GPA averages
cout << setprecision(3);
cout << "The class average test score is: " << calculateAverage<int>(tests,classSize)
<< "\nThe class average GPA is: " << calculateAverage<double>(GPAs,classSize);
return 0; // indicate that program ended successfully
} // end function main
T calculateAverage(T dataValue[], int size);
{
T total=0;
for(i=0; i<size; i++)
total = total + dataValue[i];
return(total / size);
}
I am actually getting the following errors:
C:\Data\ET486Final\CollegeApplications.cpp(84) : error C2146: syntax error : missing ';' before identifier 'calculateAverage'
C:\Data\ET486Final\CollegeApplications.cpp(84) : error C2501: 'T' : missing storage-class or type specifiers
C:\Data\ET486Final\CollegeApplications.cpp(84) : fatal error C1004: unexpected end of file found
All 3 errors point to "T calculateAverage(T dataValue[], int size);". Thank you in advance for your help.