Section 11: Branching and Looping174
2.
 Write a program that will calculate the gas and oil cost for Linda Leadfoot’s planned vacation. The car gets about 33 miles per gallon but uses a quart of oil every 350 miles. Use a conditional test to see if the mileage is greater than 350 miles. The following flowchart will help you write the program. Run the program to find the oil and gas cost for Linda’s proposed trip to Seattle, Washington. The round-trip is 494 miles. Oil is \$0.75 per quart and gas is \$0.69 per gallon. (Answers: Oil cost is \$1.06 and gas is \$10.33.)

 Start

 Prompt for & input total mileage

 Multiply by R02

 Pause to display oil cost (Label output if you wish)

 Store in R01

 Place 350 in Y-register

 LBL 01

 Y Y
 Yes Yes
 Is mileage ≤ 350?
Yesxxx
 Prompt for & input gas cost

 Go to LBL 01

 Store in R03
 Recall mileage & divide by 33
 Multiply by R03
 Pause to display total gas cost (Label ouput if you wish)
 Stop

No     No

 Prompt for & input oil cost

 Store in R02

 Recall mileage & divide by 350