Question
Modify this C++ program to use if/else if/else statements instead of a switch statement Remember Indentation (at least 4 spaces) within each block is expected.
Modify this C++ program to use if/else if/else statements instead of a switch statement Remember Indentation (at least 4 spaces) within each block is expected. All statements within a block should be aligned. Use appropriate spacing. #include using namespace std; int main() { //declare variables char grade; //prompt for user inputs cout << "What grade did you earn in Programming I ? "; cin >> grade; //display results switch (grade) // This is where the switch statement begins { case 'A': cout << "an A - excellent work !" << endl; case 'B': cout << "you got a B - good job" << endl; case 'C': cout << "earning a C is satisfactory" << endl; case 'D': cout << "while D is passing, there is a problem" << endl; case 'F': cout << "you failed - better luck next time" << endl; default: cout << "You did not enter an A, B, C, D, or F" << endl; } //end switch return 0; } //end main()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started