The switch statement

This lab lets students work with the switch statement.

Copy and paste the code below in a filename LastFirst_lab44.cpp (e.g. DoeJoe_lab44.cpp) and save it in Lab 4 folder.
Bring in the LastFirst_lab44.cpp program from the Lab 4 folder.
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?
Submit the revised LastFirst_lab44.cpp

The following is the code to be used:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// This program illustrates the use of the Switch statement.

// PLACE YOUR NAME HERE

#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;

     break;

     case 'B': cout << "you got a B - good job" << endl;

     break;

     case 'C': cout << "earning a C is satisfactory" << endl;

     break;

     case 'D': cout << "while D is passing, there is a problem" << endl;

     break;            

     case 'F': cout << "you failed - better luck next time" << endl;       

     break;  

     default: cout << "You did not enter an A, B, C, D, or F" << endl;

}

return 0;

}
You are such a meanie poo poo head!!!
:D

but so, what's your problem with this?
The problem is

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?
I think he meant "what part of the assignment is troubling you"... not "what is the assignment".

You already copy/pasted the assignment in your first post. You didn't have to copy/paste the exact same thing again.
im pretty sure this guy is a troll that does this with random assignments he finds on the internet
Or he could be a marine with kids and an assignment due who is just trying to get something to turn in until he can get a break where he'll be able to catch up with what he's missed and doesn't understand.

It's so hard to tell.
meanie poopoo head:the marines favorite sentence lmao
Topic archived. No new replies allowed.