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
|
#include <iostream>
using namespace std;
int main()
{
void getInfo(char &name, double &grade1, double &grade2, double &grade3, double &grade4);
double weighted_average(double &average, double &grade1, double &grade2, double &grade3, double &grade4);
char letter_grade(double average, char letterGrade);
int printData(char name,double &grade1, double &grade2, double &grade3, double &grade4, double average, double letterGrade);
system ("pause");
return 0;
}
void getInfo(char &name, double &grade1, double &grade2, double &grade3, double &grade4)
{
char name;
double grade1, grade2, grade3, grade4;
cout << "Enter your name" << endl;
cin >> name;
cout << "Enter your last four grades" << endl;
cin >> grade1, grade2, grade3, grade4;
}
double weighted_average(double &average, double &grade1, double &grade2, double &grade3, double &grade4)
{
double average;
return average = (grade1*.10 + grade2*.20 + grade3*.30 + grade4*.40)/4;
}
char letter_grade(double average, char letterGrade)
{
char letterGrade;
if(average >= 90)
{
average = 'A';
letterGrade = average;
cout << "Your grade is A" << endl;
}
if(average >= 80)
{
average = 'B';
letterGrade = average;
cout << "Your grade is B" << endl;
}
if(average >= 70)
{
average = 'C';
letterGrade = average;
cout << "Your grade is C" << endl;
}
if(average >= 60)
{
average = 'D';
letterGrade = average;
cout << "Your grade is D" << endl;
}
else
{
average = 'F';
letterGrade = average;
cout << "Your grade is F" << endl;
}
}
int printData(char name,double &grade1, double &grade2, double &grade3, double &grade4, double average, double letterGrade)
{
cout << "Your name is " << name << endl;
cout << "Your four grades are " << grade1 << grade2 << grade3 << grade4 << endl;
cout << "Your average is " << average << endl;
cout << "Your letter grade is " << letterGrade << endl;
}
|