In: Computer Science
C++ Code Writing prompt:
Grade Calculation: Write a program that asks the user to enter in a number greater than or equal to zero and less than or equal to 100. If they do not you should alert them and end the program. Next, determine the letter grade associated with the number. For example, A is any grade between 90 and 100. Report the letter grade to the user.
#include <iostream>
using namespace std;
int main()
{
int n;
cout<<"Enter number";
cin>>n;//read number
if(n<0 or n>100)//check if it is valid
cout<<"Invalid input"<<endl;
else if(n>=90)
cout<<"A Grade"<<endl;//print grade
return 0;
}
Screenshots:
The screenshots are attached below for reference.
Please follow them.
Please let me know in case of any help or clarification needed here in the comments section. Thank you.