Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Converter
- You want to buy this really cool car from the UK, but you are worried about the fuel consumption. The values you see are MPG (miles per gallon). You have no idea what 20 MPG means so, being a programmer, decide to write a converter that helps you calculate the consumption.
- Doing some research, you learn that 1 gallon = 4.54 litres and 1 mile = 1.6 km.
- After the calculation, round the result down to the neareast whole number.
- Input
- On the first line you will receive a number m - miles per galon
- Output
- On the only line of output, print {result} litres per 100 km
- Constraints
- 1 <= m <= 100
- Input
- 20
- Output
- 14 litres per 100 km
- Input
- 44
- Output
- 6 litres per 100 km
- C#
- using System;
- namespace _09_Converter
- {
- class Program
- {
- static void Main(string[] args)
- {
- int milesPerGalon = int.Parse(Console.ReadLine());
- if (1 < milesPerGalon || milesPerGalon < 100)
- {
- double km = (milesPerGalon * 1.0);
- double perHundred = Math.Floor(282.48 / km);
- Console.WriteLine($"{perHundred} litres per 100 km");
- }
- }
- }
- }
- Test case #4: Wrong Answer [0.03 s, 14.0 MB]
- Your output (clipped)
- 282 litres per 100 km
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement