Freelance web design - Chapter 5: Controlling Program Flow with Decision-Making Statements
Chapter 5: Controlling Program Flow with Decision-Making Statements 117 Does username equal “bburd”? no yes Unknown Does password user equal “swordfish”? no yes Figure 5-7: Don t try eating with this fork. Your basic switch statement Now, it s time to explore situations in which you have a decision with many branches. Take, for instance, the popular campfire song Al s All Wet. (For a review of the lyrics, see the sidebar.) You re eager to write code that prints this song s lyrics. Fortunately, you don t have to type all the words over and over again. Instead, you can take advantage of the repetition in the lyrics. A complete program to display the Al s All Wet lyrics won t come until Chapter 6. In the meantime, assume that you have a variable named verse. The value of verseis 1, 2, 3, or 4, depending on which verse of Al s All Wet you re trying to print. You could have a big, clumsy bunch of ifstatements that checks each possible versenumber. Incorrect You’re in password
We are dedicated to offering you a reliable, fast, and scalable unlimited web hosting home for your business, and personal web sites.Go and see our shared web hosting services.