Question: Rewrite the following C++ program using: Multiway if-statements Switch statements #include using namespace std; int main() { double grade; cout < < Enter grade (between
Rewrite the following C++ program using:
- Multiway if-statements
- Switch statements
#include
using namespace std;
int main()
{
double grade;
cout << "Enter grade (between 0 and 100):";
cin >> grade;
//--map the grade
if (grade >= 95 && grade <= 100) {
cout << "Your grade is A ";
}
if (grade >= 90 && grade < 95) {
cout << "Your grade is A- ";
}
if (grade >= 85 && grade < 90) {
cout << "Your grade is B+ ";
}
if (grade >= 80 && grade < 85) {
cout << "Your grade is B ";
}
if (grade >= 75 && grade < 80) {
cout << "Your grade is B- ";
}
if (grade >= 70 && grade < 75) {
cout << "Your grade is C+ ";
}
if (grade >= 65 && grade < 70) {
cout << "Your grade is C ";
}
if (grade >= 60 && grade < 65) {
cout << "Your grade is C- ";
}
if (grade >= 55 && grade < 60) {
cout << "Your grade is D ";
}
else{
cout << "The grade is F or you have entered an invalid grade. ";
}
system("pause");
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
