Algorithms
Example of Conditional Operation


1. read gallons_used, starting_mileage, ending_mileage

2. set distance_driven <- ending_mileage - starting_mileage

3. set average_miles_per_gallon <- distance_driven ÷ gallons_used

4. write average_miles_per_gallon

5. if average_miles_per_gallon  > 25.0 then

6.     write 'You are getting good gas mileage.' // end then

7. else

8.     write 'You are not getting good gas mileage.' // end else

9. stop
 
 

[Prev][TOC][Next]


CS1104 Main Page
Last Updated 01/05/2000
© L.Heath, 2000