info@meritcampus.com    +91-85006-22255
...

Write a program to convert length from one unit to another. Use only Inches, Centimeters, Feet, Meters, Kilometers, Miles for conversion and round off the result to two decimals. Return -1 if conversion is not possible. 1 feet=30.48 cms, 1 mt=3.2808 foot, 1 mile=1.6093 km.

Input (double, String, String) Output (double)
2.23, Kilometers, Centimeters 223000.0
21.65, Inches, Meters 0.55
68.5, Meters, Feet 224.74
56.22, Acre, Meters -1.0
6.5, Foot, Centimeters 198.12
86.4, Meters, Miles 0.05

``` class ConvertLengthToOtherUnit {     public static void main(String s[])    {        double length = 6.5;        String inputUnit = "Foot", outputUnit = "Centimeters";        System.out.println("Converting " + length + " " + inputUnit + " to " + outputUnit + " we get " + convertToOtherUnit(length, inputUnit, outputUnit));    }     public static double convertToOtherUnit(double length, String input, String output) { ```
```     }      ```
``` } ```

Topic: Learn Arrays And Loops

0
Wrong
Score more than 2 points