#include <iostream>
#include <iomanip>
using namespace std;
//global constants, global variables, function prototypes
void headerfn();
float progavgfn(int &prog1, int &prog2, int &prog3);
float testavgfn(int &test1, int &test2, int &test3);
float courseavgfn (float progavg, float testavg);
char gradefn (float courseavg);
void namefn(string &fname, string &lname);
void scoresfn(int prog1, int prog2, int prog3, int test1, int test2, int test3);
int totalfn(int prog1, int prog2, int prog3, int test1, int test2, int test3);
void outputfn(int total, float progavg, float testavg, float courseavg, char grade);
int main (){
system ("color f0");
headerfn();
string fname, lname;
namefn(fname, lname);
int prog1, prog2, prog3;
int test1, test2, test3;
int total;
float progavg, testavg, courseavg;
totalfn(prog1, prog2, prog3, test1, test2, test3);
progavgfn(prog1, prog2, prog3);
testavgfn(test1, test2, test3);
courseavgfn(progavg, testavg);
char grade='A'||'B'||'C'||'F';
gradefn(courseavg);
outputfn(total, progavg, testavg, courseavg, grade);
float progavg;
int total;
progavg=progavgfn(prog1, prog2, prog3);
progavg=(total/3);
float testavg;
int total;
testavg=testavgfn(test1, test2, test3);
testavg=(total/3);
//*****************************************************************************
void headerfn(){
cout<<"012345678901234567890123456789012345678901234567890123456789"<<endl;
cout<<"************************************************************"<<endl;
cout<<"* IT210 Business Applications with C++ *"<<endl;
cout<<"* Programmer: james lang *"<<endl;
cout<<"* Date: November 9, 2010 *"<<endl;
cout<<"* *"<<endl;
cout<<"* Program Assignment 3: Student Grades III *"<<endl;
cout<<"* *"<<endl;
cout<<"* This program uses functions to read student *"<<endl;
cout<<"* information from the keyboard and outputs *"<<endl;
cout<<"* the results to the monitor and a text file *"<<endl;
cout<<"* *"<<endl;
cout<<"************************************************************"<<endl;
cout<<endl;
cout<<"Welcome to the IT210 Grade Calculator!"<<endl;
return;
}//end of headerfn
//*****************************************************************************
void namefn(string &fname, string &lname){
cout<<"Please enter your first and last name: ";
cin>>fname>>lname;
}//end of namefn
//*****************************************************************************
void scoresfn(int &prog1, int &prog2, int &prog3, int &test1, int &test2, int &test3){
cout<<"Please enter first program score: ";
cin>>prog1;
cout<<"Please enter second program score: ";
cin>>prog2;
while (prog2<0||prog2>100){
cout<<"This score is out of range! Please enter a score between 0-100: ";
cin>>prog2;
}
cout<<"Please enter the third program score: ";
cin>>prog3;
cout<<"Please enter the first test score: ";
cin>>test1;
cout<<"Please enter the second test score: ";
cin>>test2;
cout<<"Please enter the third test score: ";
cin>>test3;
while (test3<0||test3>100){
cout<<"This score is out of range! Please enter a score between 0-100: ";
cin>>test3;
}
cout<<"1234567890123456789012345678901234567890123456789012345678901234567890"<<endl;
}//end of scoresfn
//******************************************************************************
int totalfn(int prog1, int prog2, int prog3, int test1, int test2, int test3){
return prog1+prog2+prog3+test1+test2+test3;
}//end of totalfn
//******************************************************************************
float progavgfn(int prog1, int prog2, int prog3){
return (prog1+prog2+prog3)/3;
}//end of progavgfn
//******************************************************************************
float testavgfn(int test1, int test2, int test3){
return (test1+test2+test3)/3;
}//end of testavgfn
//******************************************************************************
float courseavgfn(float testavg, float progavg){
return (progavg+testavg)/2;
}//end of courseavgfn
//******************************************************************************
char gradefn(float courseavg){
char grade;
if (courseavg>=90){
grade='A';
}
else if (courseavg>=80){
grade='B';
}
else if (courseavg>=70){
grade='C';
}
else if (courseavg<70){
grade='F';
}
return grade;
}//end of gradefn
//******************************************************************************
void outputfn(string fname, string lname, int total, float progavg,
float testavg, float courseavg, char grade){
cout<<setw(70)<<setfill('=')<<" "<<endl;
cout<<setw(20)<<setfill(' ')<<"Student Name"<<setw(10)<<"Total"
<<setw(10)<<"Program"<<setw(10)<<"Test"<<setw(10)<<"Course"<<setw(10)
<<"Grade"<<endl;
cout<<setw(20)<<setfill(' ')<<" "<<setw(10)<<"Points"<<setw(10)<<"Average"
<<setw(10)<<"Average"<<endl;
cout<<setw(70)<<setfill('-')<<" "<<endl;