Write a Java program to convert centimeters to meters and kilometers. As we know, 1 Meter = 100 and 1 Kilometer = 100000 Centimeters.
package Remaining; import java.util.Scanner; public class CMToMeterKM { private static Scanner sc; public static void main(String[] args) { sc= new Scanner(System.in); System.out.print("Please Enter the Length in Centimeters = "); double centimeter = sc.nextDouble(); double meter = centimeter / 100.00; double kilometer = centimeter / 100000.00; System.out.println("Length in Meters = " + meter); System.out.println("Length in KiloMeters = " + kilometer); } }
Please Enter the Length in Centimeters = 7502238
Length in Meters = 75022.38
Length in KiloMeters = 75.02238