Design and run a program that takes a numerical score and outputs a letter grade
ID: 3550968 • Letter: D
Question
Design and run a program that takes a numerical score and outputs a letter grade. Specific numeral scores and letter grades are listed below.
In this program, create two void functions titled getScore and printGrade with an int argument. The function getScoreshould have a Reference parameter and printGrade should have a Value parameter.
90-100
=
Grade A
80-89
=
Grade B
70-79
=
Grade C
60-69
=
Grade D
0-59
=
Grade F
The function getScore will prompt the user for the numerical score, get the input from the user, and print the numerical score. The function printGrade will calculate the course grade and print the course grade. (Be careful and note that the assignment requires you to input the grade into getScore and not directly into the main function.)
Do not forget to put in the proper prompts and appropriate output messages. (Note: This program is a natural for use of the switch command, but if?else structures will also work.)
90-100
=
Grade A
80-89
=
Grade B
70-79
=
Grade C
60-69
=
Grade D
0-59
=
Grade F
Explanation / Answer
Formatted code here: https://gist.github.com/bitwiser/9197433
#include<iostream>
using namespace std;
void getScore(int &a){
cout<<"Enter score(0-100): ";
cin>>a;
cout<<"You entered: "<<a<<endl;
}
void printGrade(int a){
if(a>=0 && a<=59){
cout<<"Grade F ";
}else if(a>=60 && a<=69){
cout<<"Grade D ";
}else if(a>=70 && a<=79){
cout<<"Grade C ";
}else if(a>=80 && a<=89){
cout<<"Grade B ";
}else if(a>=90 && a<=100){
cout<<"Grade A ";
}
}
int main(){
int score;
getScore(score);
printGrade(score);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.