{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

cs31 lecture 2

# 18 problem definition x inputs m the number of miles

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ne our formalization of the problem! 18 Problem definition x Inputs: m: the number of miles done sine last refueling g: the number of gallons of gas consumed since last refueling c: the capacity of the gas tank (in gallons) defaultMpg: the usual average mpg of the car x Rules: Hypothesis: the car will have the same mpg for the rest of the Hypothesis: tank than it achieved since the last refuel. tank 19 Problem definition x Rules: If m = 0, then mpg is defaultMpg, else mpg is m / g If m is negative (sensor default), then mpg is defaultMpg If g is negative (sensor default), then milesToRefuel is unknown We assume c and defaultMpg have no error (constants for the car) If g = 0 and m > 0 (electric), then mpg is ‘infinity’ • We select a numerical value, eg, 99, for the mpg in this case 20 A more complete algorithm Algorithm ComputeMilesLeft: IInput: nput: • • • • m: number of miles since last refuel g: number of gallons consumed since last refuel c: the capacity of the gas tank (in gallons) defaultMpg: the default mpg of the car Output: • milesToRefuel: the number of miles before refuel is n...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern