In: Computer Science
In this lab, I want you to take in a numeric grade as an integer and then print a letter grade per the table below:
90 or above is an A
80 or above is a B
70 or above is a C
60 or above is a D
Below a 60 is an F
You must use a branching statement that prints the appropriate letter grade based on the user input2. Please comment your code
Code is as follows as per the problem statement:
#include <iostream>
using namespace std;
int main() {
int grade=0;
cout<<"Enter the grade(number) : "; //marks secured is given as an input to the program
cin>>grade;
if (grade>=90) //condition check for giving A grade
cout<<"\n Grade Secured is A";
else if(grade>=80) //condition check for giving B grade
cout<<"\n Grade Secured is B";
else if(grade>=70) //condition check for giving C grade
cout<<"\n Grade Secured is C";
else if(grade>=60) //condition check for giving D grade
cout<<"\n Grade Secured is D";
else
cout<<"\n Grade Secured is F"; //if the above conditions fail then give grade as F
return 0;
}
Dear Student, As you have not mentioned the programmming language to be used for the problem statement, I have given the answer in C++ as it is widely acceptable.
Explanation:
Keep Learning!