Download presentation
Presentation is loading. Please wait.
1
Selection Structures (Part 1)
by Yonglei Tao
2
Conditional Statements
Write an algorithm that asks the user for two numbers, and print the larger one. Get the values of a, b from user If the value of a is greater than the value of b then print “The larger number is ” & a Else print “The larger number is ” & b Test 1: What does the program print if the user enters 10, 3? Test 2: What does the program print if the user enters 2, 11?
3
Conditional Statements (Cont.)
Write an algorithm to compute the distance traveled and the average miles per gallon on a trip when given as input the number of gallons used and the starting and ending mileage readings on the odometer. get gallons, start, end distance = end – start mpg = distance / gallons print mpg if mpg > 25.0 then print “You are getting good gas mileage”
4
Example One
5
Flowchart
7
Example Two
8
Flowchart
10
Example Three
11
The Select Case Statement
12
Example Four
14
Problem Specification
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.