// Lab Homework 12
// Using a switch statement to replace an if...else if...else
if...else
#include <iostream>
#include <cctype> // for toupper()
using namespace std;
int main()
{
/* Create a program that produces the Sample Output shown at the bottom.
You MUST:
- Output all of the lines show below in the Sample
Output - spacing, spelling, punctuation, etc. must be exact
matches
NOTE: There are THREE different runs of the program
shown - do not have your program do all three at once
- Declare variables and/or constants appropriately,
name them according to standards
(points will be deducted for poor names), and be sure
to use appropriate data types
- NOTE: Do NOT use if...else, you MUST use a single
switch statement
The messages you must use for each park are as
follows:
=======================================================================================================
Animal Kingdom: You chose Animal Kingdom. Be sure to
ride Kilamanjaro Safari!
EPCOT: You chose EPCOT. Be sure to go on Test
Track!
Great America: You chose Great America. Do you have
the guts to try Maxx Force Launch Coaster?
Hollywood Studios: You chose Hollywood Studios. Say
"Hi" to Han while you fly the Millenium Falcon!
Magic Kingdom: You chose Magic Kingdom. The Happily
Ever After fireworks are astounding!
Universal Studios Orlando: You chose Universal
Orlando. Be sure to say "Hi" to Harry Potter!
If a valid letter is not selected: You made an invalid
selection.
*/
// <write your solution code below this
comment>
return 0;
}
/* Sample interaction and output:
Run the program once - the user enters h
==========================================
Choose which theme park you want to attend:
(A)nimal Kingdom, (E)PCOT, (G)reat America, (H)ollywood
Studios,
(M)agic Kingdom, or (U)niversal Studios Orlando: h
You chose Hollywood Studios. Say "Hi" to Han while you fly the Millenium Falcon!
Press any key to continue . . .
Run the program a second time - the user enters U
==========================================
Choose which theme park you want to attend:
(A)nimal Kingdom, (E)PCOT, (G)reat America, (H)ollywood
Studios,
(M)agic Kingdom, or (U)niversal Studios Orlando: U
You chose Universal Orlando. Be sure to say "Hi" to Harry Potter!
Press any key to continue . . .
Run the program a third time - the user enters 7
==========================================
Choose which theme park you want to attend:
(A)nimal Kingdom, (E)PCOT, (G)reat America, (H)ollywood
Studios,
(M)agic Kingdom, or (U)niversal Studios Orlando: 7
You made an invalid selection.
Press any key to continue . . .
Feel free to run several more tests to check that each option works properly.
*/
#include <iostream>
#include <cctype> // for toupper()
using namespace std;
int main()
{
char visit_place;
cout<<"Choose which theme park you want to attend:\n(A)nimal
Kingdom, (E)PCOT, (G)reat America, (H)ollywood
Studios,"<<endl;
cout<<"(M)agic Kingdom, or (U)niversal Studios Orlando:
";
cin>>visit_place;
visit_place=toupper(visit_place);
//switch case to selection
switch(visit_place)
{
case 'A':
cout<<"You chose Animal Kingdom. Be sure to ride Kilamanjaro
Safari!"<<endl;
break;
case 'E':
cout<<"You chose EPCOT. Be sure to go on Test
Track!\n";
break;
case 'G':
cout<<"You chose Great America. Do you have the guts to try
Maxx Force Launch Coaster?"<<endl;
break;
case 'H':
cout<<"You chose Hollywood Studios. Say \"Hi\" to Han while
you fly the Millenium Falcon!"<<endl;
break;
case 'M':
cout<<"You chose Magic Kingdom. The Happily Ever After
fireworks are astounding!"<<endl;
break;
case 'U':
cout<<"You chose Universal Orlando. Be sure to say \"Hi\" to
Harry Potter!"<<endl;
break;
default:
cout<<"You made an invalid selection."<<endl;
break;
}
return 0;
}
// Lab Homework 12 // Using a switch statement to replace an if...else if...else if...else #include...