Write a COMPLETE C++ program to ask the user to enter a grade. If the grade is g
ID: 3929980 • Letter: W
Question
Write a COMPLETE C++ program to ask the user to enter a grade. If the grade is greater than or equal to 60, but less than or equal to 100, the program will display "Congratulation! You passed the exam." If the grade is less than 60, hut greater than or equal to 0, the program will display "You failed the test, Work harder." If the grade is not within the range from 0 to 100, the program will display "Invalid grade." The following is a sample running result: Running example 1: Please enter your grade. 89 Congratulation! You passed the exam. Press any key to continue..... Running example 2: Please enter your grade: 55 You failed the test. Work harder. Press any key to continue..... Running example 3: Please enter your grade: 105 Invalid grade. Press any key to continue....Explanation / Answer
#include <iostream>
using namespace std;
int main(void)
{
int mark;
cout<<"Enter student's mark: ";
cin>>mark;
if (mark < 40)
cout<<"Student grade = F";
else if (mark < 50)
cout<<"Student grade = E";
else if (mark < 60)
cout<<"Student grade = D";
else if (mark < 70)
cout<<"Student grade = C";
else if (mark < 80)
cout<<"Student grade = B";
else
cout<<"Student grade = A";
cout<<" ";
return 0;
}
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.