-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path26_switch_no_break.cpp
More file actions
57 lines (51 loc) · 1.27 KB
/
26_switch_no_break.cpp
File metadata and controls
57 lines (51 loc) · 1.27 KB
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
50
51
52
53
54
55
56
57
/*Goal: understand the switch statement in C++
**This example does not use a break statement between
**the possibilities, which means all menu items below the selected
**one are executed.
*/
#include<iostream>
int main()
{
char menuItem;
std::cout<<"Choose your holiday package:\n";
std::cout<<"L: luxury package\nS: standard package\n";
std::cout<<"B: basic package ";
std::cin>>menuItem;
std::cout<<menuItem<<"\n";
std::cout<<"The "<<menuItem<<" package includes:\n";
switch(menuItem)
{
case 'L':
{
std::cout<<"\tSpa Day\n";
std::cout<<"\tSailboat Tour\n";
}
case 'S':
{
std::cout<<"\tCity Tour\n";
std::cout<<"\tComplimentary Happy Hour\n";
}
case 'B':
{
std::cout<<"\tAirport Transfers\n";
std::cout<<"\tComplimentary Breakfast\n";
break;
}
default:
std::cout<<"Please select the L,S,B package.\n";
}
return 0;
}
/*If you select L
Choose your holiday package:
L: luxury package
S: standard package
B: basic package L
The L package includes:
Spa Day
Sailboat Tour
City Tour
Complimentary Happy Hour
Airport Transfers
Complimentary Breakfast
*/