Once you feel comfortable with the above content, complete the following practice program.
Rewrite the Fate
program using switch/case statements.
Give the user the option to drink a yellow potion or a green potion (use a
string
). Give the user the option to open to pick door one or two (use anint
).
- If the user drinks the yellow potion and goes through door one, the user finds a pony.
- If the user drinks the green potion and goes through door one, the user gets eaten by rainbow zombies.
- If the user drinks the green potion and goes through door two, the user flies to Florida and retires.
- If the user drinks the yellow potion and goes through door two, the user falls into a bowl full of kittens.
- If the user fails to drink a potion, the user dies.
- If the user fails to enter either door, the user runs INTO A DOOR!
← 1-3 Loops | 1-4 Switch/Case Statements | Chapter 2: Organization → |