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
|
//preprocessor directives
#include <iostream>
#include <string>
//namespace statement
using namespace std;
//function prototypes
void getData (string& course, string& first, string& last, int& grade);
void testGrade (int grade, bool& passFail);
void determineGrade (int grade, string& letterGrade);
void printResults (bool pressFail, string first, string last, string course, string letterGrade);
//main function
int main (){
//declare a variable called course that can hold words
string course;
//declare a variable called first that can hold words
string first;
//declare a variable called last that can hold words
string last;
//declare a variabele called letterGrade that can hold words
string letterGrade;
//declare a variable called int that can whold numbers
int grade;
//declare a variable called passFail that can hold bool
bool passFail;
//function calls
getData (course, first, last, grade);
testGrade (grade, passFail);
//print "Press any key to continue..." and wait for key press
system ("pause");
//end main function
return 0;
}
void getData (string& course, string& first, string& last, int& grade){
//prompt the user to "Enter your course:"
cout << "Enter your course:" << endl;
//wait for input and store in course
cin >> course;
//prompt the user to "Enter your First Name:"
cout << "Enter your First Name:" << endl;
//wait for input and store in first
cin >> first;
//prompt the user to "Enter your Last Name:"
cout << "Enter your Last Name:" << endl;
//wait for input and store in last
cin >> last;
//prompt the user to enter your grade
cout << "Enter your grade:" << endl;
//wait for input and store in grade
cin >> grade;
}
void testGrade (int grade, bool& passFail){
//test to see if grade is higher than 65
if (grade > 65){
//if true than they pass and pring "Pass!"
passFail = true;
cout << "Pass!";
}else if (grade < 65){
passFail = false;
cout << "Fail!";
}
}
void determineGrade (int grade, string& letterGrade){
//check to see if grade is 90 or above
if ((grade > 90) && (grade <= 100)){
}else if ((grade > 80) && (grade <= 89)){
letterGrade = B;
|