cs31 lecture 2

Cs31 lecture 2

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

View Full Document Right Arrow Icon
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

This note was uploaded on 04/03/2014 for the course CS 31 taught by Professor Melkanoff during the Fall '00 term at UCLA.

Ask a homework question - tutors are online