Write a program that can compute the average of a student\'s class containing 5
ID: 3769737 • Letter: W
Question
Write a program that can compute the average of a student's class containing 5 categories (Homework, midterm exam, final exam, project and unit test.)
Grading Scale:
Homework: 10%
Midterm exam: 10%
Final exam: 25%
Project: 15%
Unit test: 40%
A:90-100
B:80-89
C:70-79
D:60-69
F:<60
The program must display the grade for each category, the computed
overall average and the resulting letter grade.
Must Implement your solution using a class.
----------------------------------------------
Homework average (10%): 93.3
Unit Tests average (40%): 83.8
Midterm Exam (10%): 81.0
Final Exam (25%): 74.0
Project (15%): 100.0
--------------------------------------
Computed Overall Average: 84.5 ==> letter grade:B
Explanation / Answer
#include<iostream.h>
#include<conio.h>
class exam
{
public:
void cal(double h, double mt, double fe, double pr, double ut)
{
double hp,mtp,fep,prp,utp;
hp=h*10/100;
mtp=mt*10/100;
fep=fe*25/100;
prp=pr*15/100;
utp=ut*40/100;
char gr;
double av=hp+mtp+fep+prp+utp;
//double av=tot/5;
if(av>=90 && av<=100)
{
gr='A';
}
if(av>=80 && av<=89)
{
gr='B';
}
if(av>=70 && av<=79)
{
gr='C';
}
if(av>=60 && av<=69)
{
gr='D';
}
if(av<60)
{
gr='F';
}
cout<<"Homework average (10%): "<<hp<<endl;
cout<<"Unit Tests average (40%):"<<utp<<endl;
cout<<"Midterm Exam (10%): "<<mtp<<endl;
cout<<"Final Exam (25%): "<<fep<<endl;
cout<<"Project (15%): "<<prp<<endl;
cout<<"Computed Overall Average: "<<av<<" ==> letter grade:"<<gr;
}
};
void main()
{
exam o;
o.cal(90,90,90,90,90);
getch();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.