Design and run a program that takes a numerical score andoutputs a letter grade.
ID: 3619010 • Letter: D
Question
- Design and run a program that takes a numerical score andoutputs a letter grade. Specific numerical scores and letter gradesare listed below:
In this program, create two void functions titled getScoreand printGrade with an int argument. The functiongetScore should have a Reference parameter andprintGrade should have a Value parameter.
The function getScore will prompt the user for thenumerical score, get the input from the user, and print thenumerical score. The function printGrade will calculatethe course grade and print the course grade. (Be careful and notethat the assignment requires you to input the grade intogetScore and not directly into the mainfunction.)
Do not forget to put in the proper prompts and appropriate outputmessages. (Note: This program is a natural for useof the switch command, but if?else structureswill also work.) 90-100 = Grade A 80-89 = Grade B 70-79 = Grade C 60-69 = Grade D 0-59 = Grade F 90-100 = Grade A 80-89 = Grade B 70-79 = Grade C 60-69 = Grade D 0-59 = Grade F
Explanation / Answer
#include<iostream.h> double getMarks(); void print_Grade(double grade);double getMarks() { double grade = 0; cout<<" Enter the grade ="; cin>>grade; return grade; }
void print_Grade(double grade) { if((grade>=90)&&(grade<=100)) { cout<<"Grade A "<<endl; } else if((grade>=80)&&(grade<=90)) { cout<<"Grade B"<<endl; }else if((grade>=70)&&(grade<=79)) { cout<<"Grade C"<<endl; } else if((grade>=60)&&(grade<=69)) { cout<<"Grade D"<<endl; } else if((grade>=0)&&(grade<=59)) { cout<<"Grade F"<<endl; }
} void main() { double grade = 0; grade=getMarks(); print_Grade(grade);
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.