- 1
I got a challenge java code a object oriented programming
1. Write a java program to convert car consumption from one unit to another. Offer the user the choice of either conversion, kpl to mpg or mpg to kpl. The interface should be: PREFERRED CONVERSION: 1. kpl to mpg 2. mpg to kpl Enter your choice: 2 Enter miles per gallon value: mpg_value The equivalent kilometers per liter is: kpl_value Use the constants 1 mile = 1609 meters and 1 gallon = 3.785 liters. Useful formula: mpg = (kpl / 1.609) * 3.785 kpl = (mpg * 1.609) / 3.785 Note: the output of the program above should be formatted to 2 decimal places using the method System.out.printf().
1 Odpowiedź