Chapter 7 lesson 3
Which of the following can be placed inside the parentheses of a switch() statement?
All of these are true
Given the following code, what will the messageText.text property contain at the end? string breakfast = "BACON"; switch (breakfast){case "bacon":messageText.text = "Mmmmmm, bacon";break;case "sausage":messageText.text = "Yummy sausage";break;default:messageText.text = "So hungry";break;}
So hungry
Given the code below, what value is stored in the messageText.text property at the end? int landing = 2;switch(landing){case 0:case 1:case 2:case 3:messageText.text = "Walk away";break; default:messageText.text = "Medic!";break; }
Walk away
What is wrong with the following code? float gamePrice = 59.99F; switch(gamePrice) { case 59.99: messageText.text = "Just right"; break; default: messageText.text = "wrong price"; break; }
You can't use a float variable or expression in a switch statement
Which of the following describes the differences between an if() and a switch() statement?
if() statements can use any logical expression; switch() statements can test one expression against multiple "equal to" values