Control III

Control III - 1 Flow of Control Part II Department of...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 Flow of Control Part II Department of Computer Science APSC 160 Flow of Control Part III Learning Goals By the end of this section, you should be able to: write the code for simple branching read code that includes branching develop a plan for testing code that includes a develop a plan for testing code that includes a branch Branching if( Boolean ) { /* true block */ } Example: Develop a program that prompts the user for the number of gallons of gas in a car and the number of miles they wish to travel. If there is sufficient gas for the trip, the program should show the number of gallons of gas remaining at the end of the trip. In all cases, the program prints the message "Done" before terminating. Assume that the car gets 30 miles to the gallon. Flowchart Code 2 Test gasInCar distance gasRemaining 10.0 30.0 9.0 Test gasInCar distance gasRemaining 10.0 400.0 not printed Branching if( Boolean ) { /* true block */ } else { /* false block */ } Example: Develop a program that prompts the user for the...
View Full Document

Page1 / 3

Control III - 1 Flow of Control Part II Department of...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online