Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- double CalcAverage(double t1, double t2)
- {
- double avg;
- avg = (t1 + t2) / 2.0;
- return(avg);
- }
- char GradeConvert(double avg)
- {
- char grade;
- if(avg >= 90){
- grade = 'A';
- }
- else if(avg >= 80){
- grade = 'B';
- }
- else if(avg >= 70){
- grade = 'C';
- }
- else if(avg >= 65){
- grade = 'D';
- }
- else{
- grade = 'F';
- }
- return(grade);
- }
- void PrintRecord(string course, string name, double num, char letter)
- {
- system("cls");
- cout << "Course: " << course << endl;
- cout << "\n Student: " << name << endl;
- cout << " Numeric Average: " << num << endl;
- cout << " Letter Grade: " << letter << endl;
- cout << "\n";
- system("pause");
- }
- int main()
- {
- string c, n;
- double t1, t2, a;
- char l, r;
- do{
- system("cls");
- cout << "Enter course: ";
- getline(cin, c);
- cout << "Enter name: ";
- getline(cin, n);
- cout << "Enter midterm and finals grades:" << endl;
- cin >> t1;
- cin >> t2;
- a = CalcAverage(t1, t2);
- l = GradeConvert(a);
- PrintRecord(c, n, a, l);
- cout << "\nWould you like to enter another course(y/n): ";
- cin >> r;
- cin.ignore();
- }while(r == 'y');
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement