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
|
#include <iostream>
#include <iomanip>
using namespace std;
//function prototypes
void getGradeInfo(int& c1credits, char& c1grade, int& c2credits, char& c2grade);
int getQualityPoints(int c1credits,char& c1grade,char& c2grade,int c2credits);
void computeGPA(int c1credits,char c1grade,int c2credits,char c2grade,int& qpl1,int& qpl2,double gpa);
void printReport(int c1credits,char c1grade,int c2credits,char c2grade,int qpl1,int qpl2,double gpa);
int main()
{
int c1credits, c2credits, qpl1, qpl2;
double gpa;
char c1grade, c2grade;
getGradeInfo(c1credits, c1grade, c2credits, c2grade);
computeGPA(c1credits, c1grade, c2credits, c2grade, qpl1, qpl2, gpa);
printReport(c1credits, c1grade, c2credits, c2grade, qpl1, qpl2, gpa);
system("PAUSE");
return 0;
}//end of main
void getGradeInfo(int& c1credits, char& c1grade, int& c2credits, char& c2grade)
{
cout<<"Enter the # of credits and your grade for class #1 "<<endl;
cin>>c1credits>>c1grade;
cout<<"Enter the # of credits and your grade for class #2 "<<endl;
cin>>c2credits>>c2grade;
}
int getQualityPoints(int c1credits,char& c1grade,char& c2grade,int c2credits)
{
if(c1grade=='A')
c1grade=4;
else if(c1grade=='B')
c1grade=3;
else if(c1grade=='C')
c1grade=2;
else if(c1grade=='D')
c1grade=1;
else
c1grade=0;
return c1grade;
if(c2grade=='A')
c2grade=4;
else if(c2grade=='B')
c2grade=3;
else if(c2grade=='C')
c2grade=2;
else if(c2grade=='D')
c2grade=1;
else
c2grade=0;
return c2grade;
}
void computeGPA(int c1credits,char c1grade,int c2credits,char c2grade,int& qpl1,int& qpl2,double gpa)
{
qpl1=c1credits*getQualityPoints(c1credits,c1grade,c2grade,c2credits);
qpl2=c2credits*getQualityPoints((c1credits,c1grade,c2grade,c2credits);
}
void printReport(int c1credits,char c1grade,int c2credits,char c2grade,int qpl1,int qpl2,double gpa)
{
cout<<"quality points "<<qpl1<<" "<<qpl2<<endl;
}
|