0

Please can somebody help me with the line of codes of this question:write a C++ program which inputs litre consumption given in miles/gallon and which translates these figures into the litres/kilometre format which is more common in Europe.Use the following conversion factors: 1 mile=1.609km and 1 gallon= 3.785litres

4
Contributors
3
Replies
13
Views
3 Years
Discussion Span
Last Post by Banfa
0

The values you need are km per mi and gl per lt not lt per gl
1mi=1.609km
1lt=0.264172gl

lt/km = (mi/gl) * (km/mi) * (gl/lt)
lt/km = (given) * 1.609 * 0.264
lt/km = (given) * 0.425

Hope that helps.

0

Can get you started...

#include <iostream>

You're going to need a "main" function.
cin.
cout.
and a bit of mathematics.

Edited by Suzie999

0

Normally it's liters/100 kilometers but ignoring that detail.

If you have C in miles/gallon then you need to do 3 convertions

miles -> kilometers = times by 1.609
gallon -> liters = times by 3.785 (but note that gallons in underneath the line
distance/volume -> volume/distance = 1/x

so C miles/gallon === 1/(1.609C/3.785) = 3.785/1.609C liters/kilometer

So 30 mpg = 0.0784 liters/kilometer

Which as you can see is very small which is why liters/100 kilometer is more common

So 30 mpg = 7.8 liters/100 kilometer

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.