C++
1. Write a program that determines a student’s grade. The program will read three types of scores
(quiz, mid-term, and final scores), calculate the average and determine the grade based on the
following rules:
90% and above: A
80%-89%: B
70%-79%: C
50%-60%: D
0-49%: F
#include <iostream> using namespace std; char getLetterGrade(double score){ char letter; if(score < 60) letter = 'F'; else if(score < 70) letter = 'D'; else if(score < 80) letter = 'C'; else if(score < 90) letter = 'B'; else letter = 'A'; return letter; } int main(){ double quiz, midTerm, final, avg; cout<<"Enter quiz score: "; cin>>quiz; cout<<"Enter mid term score: "; cin>>midTerm; cout<<"Enter final score: "; cin>>final; avg = (quiz + midTerm + final)/3; cout<<"Average = "<<avg<<endl; cout<<"Letter grade = "<<getLetterGrade(avg)<<endl; return 0; }
Get Answers For Free
Most questions answered within 1 hours.