## Thursday, August 15, 2013

### Grade Calculator

#include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;

//Function Prototype.
int getProExScore();
int getQuizScore();
int getMidTerm();
int getFinal();
int calculateAverage(int);
void studentNumber();
void displayGrades(int gradeA, int gradeB, int gradeC,int gradeD, int gradeF);

int main ()

{

//declare variables
int studentNumber;
int gradeA,gradeB,gradeC,gradeD,gradeF;
//call studentNumber Fuction
void studentNumber();

gradeA = 0;
gradeB= 0;
gradeC=0;
gradeD =0
gradef =0

//call displayGrades Fuction.
void displayGrades();

system("pause");
return 0;

//declare students Number fuction.
void getNumberofStudents();
int studentNumber;
{

cout<<"Please enter the number of students in the class"<<endl;

cin>>studentNumber;

while(studentNumber<0||studentNumber>100)
{
cout<<"Error!!!! student Number can't be less than 0 or more than 100"<<endl;
cout<<"Please enter the number of students in the class"<<endl;
cin>>studentNumber;
}
}
//get Program Exercises Grade.

int getProExScore()
{
int proEx =0;

proEx = rand()%100+1;
return proEx;
}

//get quiz score grades.
int getQuizScore()
{
int quiz =0;
quiz = rand()%100+1;
return quiz;
}
}
//get mid term grades.
int getMidTerm()
{
int midTerm =0;
midTerm = rand()%100+1;
return midTerm;
}

//get final grades
int getFinal()
{
int final =0;
final = rand()%100+1;
return final;
}

//calculate students grade.
int calculateAverage(int StudentNumber)
{

for (int i = 0; i<studentNumber; i++)
{
double grade;

grade = (getQuizScore()*0.75) + ( getQuizScore()*0.10) + (getMidTerm() *0.05) + (getFinal()*0.10);
return grade;
if (grade<=100)
{
cout<<"The Grade is A"<<endl;
gradeA++;
}
else if(grade <=90)
{
cout<<"the grade is B"<<endl;
gradeB++;
}
else if(grade <=80)
{
cout<<"the grade is c"<<endl;
gradeC++;
}
else if(grade <=70)
{
cout<<"the grade is D"<<endl;
gradeD++;
}
else
{
cout<<"The grade is F"<<endl;
gradeF++;
}

}

//display results.
void displayGrades(int gradeA, int gradeB, int gradeC,int gradeD, int gradeF)
{

cout<<"The amount of A in the class is:"<<gradeA<<endl;
cout<<"The amount of B in the class is:"<<gradeB<<endl;
cout<<"The amount of C in the class is:"<<gradeC<<endl;
cout<<"The amount of D in the class is:"<<gradeD<<endl;
cout<<"The amount of F in the class is:"<<gradeF<<endl;

}