I keep coming up with 2 errors with my code. These are the errors
||In function 'double arrayLabAve(int, double*)':|
|188|error: a function-definition is not allowed here before '{' token|
|214|error: expected '}' at end of input|
||=== Build finished: 2 errors, 0 warnings ===|
Here is my
Any help would be great.Code:#include <iostream> using namespace std; #define Max_Students 10 int grades; int eScores; int lScores; int getStudentCount(); int getExamScores(int,float*); int getLabScores(int,float*); void calculatePointGrades(float[],int,float[]); void calculateLetterGrades(int,float[]); float ExamGrade[Max_Students]; float LabGrade[Max_Students]; float PointGrade[Max_Students]; char LetterGrade[Max_Students]; void showGradeData(double[],double[],char[], double[],int); double arrayExamAve(int, double[]); double arrayLabAve(int, double[]); void arrayLetterGrades(int, double[]); void arrayPointGrades (int, double[]); // Declare functions here, include the necessary parameters here and in the actual functions below. // (once the function prototypes are created, the main() // function can be moved back to the top of the code.) // Declare the arrays here void display(int); int main() { int NumStudents; NumStudents = getStudentCount(); getExamScores(NumStudents, ExamGrade); getLabScores(NumStudents, LabGrade); calculatePointGrades(ExamGrade,NumStudents,LabGrade); calculateLetterGrades(NumStudents,PointGrade); display(NumStudents); cin.ignore(2); } int getStudentCount() // functions that gets total number of students { int StudentInput; cout << "Enter the number of students: "; cin>>StudentInput; cout<<endl; return StudentInput; } int getExamScores (int count , float *Grade) // function that gets Exam Grade { cout<<endl; for (int student = 0; student <count; ++student) { cout << "enter exam grade for student "<< student+1 <<": "; cin >> *Grade; Grade++; } cout<<endl; return 0; } int getLabScores (int count , float *Grade) // function that get Lab Average grade { cout<<endl; for (int student = 0; student <count; ++student) { cout << "enter lab grade for student "<< student+1 <<": "; cin >> *Grade; Grade++; } cout<<endl; return 0; } void calculatePointGrades(float LabGrade[],int count, float ExamGrade[]) // function that calculates Point Grade by getting ExamGrade and LabAverage as arguments { for (int student = 0; student < count; student++) { PointGrade[student] = (.7*ExamGrade[student]) + (.3*LabGrade[student]); } } void calculateLetterGrades(int count,float PointGrade[]) // function that calculates Letter Grades based on Point Grade { for (int student = 0; student < count; ++student) { if(PointGrade[student]>=90) LetterGrade[student]='A'; else if(PointGrade[student]>=80 && PointGrade[student]<90) LetterGrade[student]='B'; else if(PointGrade[student]>=70 && PointGrade[student]<80) LetterGrade[student]='C'; else if(PointGrade[student]>=60 && PointGrade[student]<70) LetterGrade[student]='D'; else LetterGrade[student]='F'; } } void showGradeData(double arrayExamAve[],double arrayLabAve[],char arrayLetterGrades[], double arrayPointGrades[],int getStudentCount ) // Prints a table of the student's scores and grades from the arrays { cout << arrayExamAve[eScores] << arrayLabAve[lScores] << arrayLetterGrades[grades] << arrayPointGrades[grades]; cout <<endl; // this statement is used for intial test and debugging // returns no values to main } double arrayExamAve(int numStudents,double arrayExamAve[]) // Averages the student's numeric exam grades from the array { int eScores=0; int sum=0; int ave=0; for (sum = 0; sum <= numStudents; sum++) { sum = sum + arrayExamAve[eScores]; ave = sum/numStudents; } // this statement is used for intial test and debugging return ave; // returns average exam score to main } double arrayLabAve(int numStudents,double arrayLabAve[]) // Averages the student's numeric lab grades from the array { int lScores=0; int sum=0; int aveg=0; for (sum = 0; sum <= numStudents; sum++) { sum = sum + arrayLabAve[lScores]; aveg = sum/numStudents; } void display(int count) // function that display the mark details along with total average { int TotalExamGrade=0; float TotalLabGrade=0.0,TotalPointScore=0.0; // variables for finding total float AvgExamGrade,AvgLabGrade,AvgPointScore; // variables for finding average cout<<"\n\nSNO"<<"\t"<<"EXAM SCORE"<<"\t"<<"LAB SCORE"<<"\t\t"<<"POINT GRADE"<<"\t"<<"LETTER GRADE"<<endl; for(int student=0; student<count ; student++) { cout<<student+1<<"\t"<<ExamGrade[student]<<"\t\t"<<LabGrade[student]<<"\t\t"<<PointGrade[student]<<"\t\t"<<LetterGrade[student]<<endl; TotalExamGrade = TotalExamGrade + ExamGrade[student]; TotalLabGrade = TotalLabGrade + LabGrade[student]; TotalPointScore = TotalPointScore + PointGrade[student]; } AvgExamGrade = (float)TotalExamGrade / count; AvgLabGrade = TotalLabGrade / count; AvgPointScore = TotalPointScore / count; cout<<"\n\n Exam Average : "<<AvgExamGrade; cout<<"\n Lab Average Average : "<<AvgLabGrade; cout<<"\n Point Score Average : "<<AvgPointScore; }
Thanks



LinkBack URL
About LinkBacks


