Hi i'm more confused by how the teacher worded this assignment than the fundamentals of C++ but maybe someone could help clarify.
Teachers instructions :This lab lets students work with the switch statement.
Remove the break statements from each of the cases. What is the effect on the execution of the program?
Add an additional switch statement that allows for a Passing option for a grade of D or better. Use the sample run given below to model your output.
Sample Run: What grade did you earn in Programming I ? A YOU PASSED! an A - excellent work!
Rewrite the program LastFirst_lab44.cpp using if and else if statements rather than a switch statement. Did you use a trailing else in your new version? If so, what did it correspond to in the original program with the switch statement?
// This program illustrates the use of the Switch statement.
// The break statement causes all subsequent expressions to be executed as well, also known as "falling through".
//
// The trailing else statement acts just like the default section if none of the options from before work it gets "defaulted" to it.
#include <iostream>
using namespace std;
int main()
{
char grade;
cout << "What grade did you earn in Programming I ?" << endl;
cin >> grade;
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;
}
return 0;
}
My question : how do you add an additional switch statement? i tried multiple times and i'm not sure if i don't understand braces enough but it didnt seem doable. also, I'm not sure what the teacher wants me to submit.