//Preprocessor Directives
#include<iostream>
#include<iomanip>
#include<fstream>
using namespace std;
//Global variables/constants, function prototypes
void headerfn();//void function with no parameters
void inputfn(string &fname, string &lname, int &prog1, int &prog2, int &prog3, int &test1, int &test2, int &test3);//void w/ parameters (reference)
float inputfn(string input);
int main(){
system("color f0");
headerfn();//void function call
string fname, lname;
int prog1, prog2, prog3, test1, test2, test3;
inputfn(fname, lname, prog1, prog2, prog3, test1, test2, test3);//void function call
float input;
input=inputfn(fname, lname, prog1, prog2, prog3, test1, test2, test3);
system("pause");
return 0;
}//end of main
//************************************************************
//Void Function Without Parameters
void headerfn(){
cout<<"123456789012345678901234567890123456789012345678901234567890"<<endl;
cout<<setw(60)<<setfill('*')<<"*"<<endl;
cout<<"* IT 210 Business Applications with C++ *\n";
cout<<"* Programmer: Kate Hamby *\n";
cout<<"* Date: November 02, 2009 *\n";
cout<<"* *\n";
cout<<"* Program Assignment 3: Student Grades III *\n";
cout<<"* *\n";
cout<<"* This program uses functions to read student *\n";
cout<<"* information from the keyboard and outputs *\n";
cout<<"* the results to the monitor and a text file. *\n";
cout<<setw(60)<<setfill('*')<<"*"<<endl;
}//end of headerfn
//************************************************************
//Void Function With Parameters
void inputfn(string &fname, string &lname, int &prog1, int &prog2, int &prog3, int &test1, int &test2, int &test3){
cout<<"Please enter your first and last name: ";
cin>>fname>>lname;
cout<<endl<<"Please enter the first program score: ";
cin>>prog1;
cout<<endl<<"Please enter the second program score: ";
cin>>prog2;
cout<<endl<<"Please enter the third program score: ";
cin>>prog3;
cout<<endl<<"Please enter the first test score: ";
cin>>test1;
cout<<endl<<"Please enter the second test score: ";
cin>>test2;
cout<<endl<<"Please enter the third test score: ";
cin>>test3;
//************************************************************
//Value Returning Function With Parameter
float inputfn(string &fname, string &lname, int &prog1, int &prog2, int &prog3, int &test1, int &test2, int &test3){
float input;
if (input<0) cout<<"This score is invalid! PLease enter a score between 0-100: ";
else if (input>100) cout<<"This score is invalid! PLease enter a score between 0-100: ";
return input;
}
|