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
|
#include <iostream>
using namespace std;
#define Max_Students 100
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 display(int);
void 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 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;
}
|