Question: Fix the code: Miles Per Gallon Use input to prompt for float miles driven Keep promping for miles until the entry is greater than 0

Fix the code:

 

Miles Per Gallon

Use input to prompt for float miles driven Keep promping for miles until the entry is greater than 0

Use input to prompt for float gallons used Keep promping for gallons until the entry is greater than 0

Calculate miles per gallon as miles didived by gallons, rounded to 2 decimal places

Display miles, gallons and miles per gallon

Example

Input: (bold in computer prompt; other iis user response)

Enter miles: -500 Enter miles: 500 Enter gallons: 0 Enter gallons: 18 Display Miles = 500.0 Gallons = 18.0 Miles Per Gallon = 27.78 Be sure to fill out author and date DO NOTwrite a new program Fix the current program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!