Create a userdefined function called calculate Letter Grade

Create a user-defined function called calculate Letter Grade that will return the letter grade for a student. The function should take as input one homework, one midterm, and one final. It will use this to calculate the average grade. If this average grade is above 90, the user gets and A· However, if the user gets between 80 and 89, the user gets a B. If the user gets between 70-79 the user gets a C and if the user gets between 60-69 the user gets a D. Anything below is an F.

Solution

// C++ code determine student grade

#include <iostream>
#include <string.h>
#include <fstream>
#include <limits.h>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <stdlib.h>
#include <vector>

using namespace std;

char calculateLetterGrade(double homework, double midterm, double final)
{
double average_score = (homework+midterm+final)/3;

char grade;
if(average_score > 90)
grade = \'A\';
else if(average_score >= 80)
grade = \'B\';
else if(average_score >=70)
grade = \'C\';
else if(average_score >=60)
grade = \'D\';
else
grade = \'F\';
  
return grade;
}

int main()
{
double homework,midterm,final;

cout << \"Enter homework score: \";
cin >> homework;
cout << \"Enter midterm score: \";
cin >> midterm;
cout << \"Enter final socre: \";
cin >> final;

cout << \"Student grade: \" << calculateLetterGrade(homework,midterm,final) << endl;
}

/*
output:

Enter homework score: 78.5
Enter midterm score: 67
Enter final socre: 90.5

Student grade: C

*/

 Create a user-defined function called calculate Letter Grade that will return the letter grade for a student. The function should take as input one homework, o
 Create a user-defined function called calculate Letter Grade that will return the letter grade for a student. The function should take as input one homework, o

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site