# Thread: Stuck on the standard odometer lesson

1. Member
Join Date
Mar 2014
Posts
3
Rep Power
0

## Stuck on the standard odometer lesson

Yep, another one of these. It seems my Comp Sci teacher lacks originality (and any real ability to teach), and went with this one to 'teach' us classes. Unfortunately, the majority of the people in the class don't own a car, or a license. And she did a pretty terrible job explaining it. So, while I can do classes, I can't finish the assignment, because I don't know the equation/part-of-code-that-will-most-likely-never-be-used-again.

What I'm trying to ask, is what do I have to do (nothing specific, please), to end up with a console that looks something like this:

New car odometer reading: 15

Filling Station Visit
gallons to fill tank: 10

Miles per gallon: 23.50

Filling Station Visit
gallons to fill tank: 12.5

Miles per gallon: 16.40

You know, the standard 'Calculate miles per gallon every stop at a gas station' thing. Please?

2. ## Re: Stuck on the standard odometer lesson

First step in writing any program: think about how you would do what the program needs to do. What values do you need? What would you do with those values? The rest is easy.

3. Member
Join Date
Mar 2014
Posts
3
Rep Power
0

## Re: Stuck on the standard odometer lesson

Okay...maybe I phrased this wrong...I literally know just about nothing concerning cars. I barely know what an odometer is. What I'm looking for is for someone to rephrase this in a more helpful manner, one that I can derive some sort of equation from.

4. ## Re: Stuck on the standard odometer lesson

Oh. Well, I can explain that because I do it all the time.

The idea is that each time you buy gasoline, you fill your tank to the top and record the mileage on your odometer. The next time you buy gasoline, the pump tells you how many gallons it took to fill the tank to the top again. By subtracting the previous odometer reading from the current one, you know how many miles you drove since your last fill-up. By dividing that distance by the amount of fuel you put in, you know how many miles per gallon you got.

So basically your program will need a starting odometer reading, and you assume the tank is full. Then use whatever input method you've been taught to get a series of fuel amounts and odometer readings from the user.

5. Member
Join Date
Mar 2014
Posts
3
Rep Power
0

## Re: Stuck on the standard odometer lesson

Thank you so much! I'm glad I can finally stop pounding my head against a metaphorical wall!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•