C++ program that accepts a grade from a user and outputs a letter grade
Posted by Samath
Last Updated: November 04, 2014

Write a C++ program that accepts a grade from a user and outputs a letter grade base on the following criteria:

 

Here is the Solution to the problem above:

#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
	int grade;
	cout<<"Enter grade: ";
	cin>>grade;
	
	if(grade >= 90 && grade <= 100)
	{
		cout<<"Letter Grade: A";
	}
	else if(grade >= 85 && grade <= 89)
	{
		cout<<"Letter Grade: A-";
	}
	else if(grade >= 80 && grade <= 84)
	{
		cout<<"Letter Grade: B+";
	}
	else if(grade >= 75 && grade <= 79)
	{
		cout<<"Letter Grade: B";
	}
	else if(grade >= 70 && grade <= 74)
	{
		cout<<"Letter Grade: B-";
	}
	else if(grade >= 65 && grade <= 69)
	{
		cout<<"Letter Grade: C+";
	}
	else if(grade >= 60 && grade <= 64)
	{
		cout<<"Letter Grade: C";
	}
	else if(grade >= 55 && grade <= 59)
	{
		cout<<"Letter Grade: C-";
	}
	else if(grade >= 50 && grade <= 54)
	{
		cout<<"Letter Grade: D";
	}
	else if(grade < 50)
	{
		cout<<"Letter Grade: F";
	}
	cout<<endl;
	return 0;
}