# Centimeter to micrometer – Java Program to Convert Centimeter to Micrometer and Micrometer to Centimeter

Centimeter to micrometer: In the previous article we have discussed about Java Program to Convert Centimeter to Meter and Meter to Centimeter

In this article we will see how to convert Centimeter to Micrometer and Micrometer to Centimeter by using Java programming language.

## Java Program to Convert Centimeter to Micrometer and Micrometer to Centimeter

Micrometer to centimeter: Before jumping into the program let’s know the relationship between Centimeter and Micrometer and how we can convert Centimeter to Micrometer and vice versa.

Generally Centimeter and Micrometer are used as unit in case of small length measurement.

1 Centimeter =  10000 Micrometer
1 Micrometer =  1e-4  Centimeter

Formula to convert Centimeter to Micrometer.

Micrometer = Centimeter * 10000

Formula to convert Micrometer to Centimeter.

Centimeter  = Micrometer / 10000

Let’s see different ways to convert Centimeter to Micrometer and Micrometer to Centimeter.

### Method-1: Java Program to Convert Centimeter to Micrometer and Micrometer to Centimeter By Using Static Input Value

Approach:

• Declare Centimeter and Micrometer value.
• Then convert Centimeter to Micrometer and Micrometer to Centimeter by using the formula.
• Print result.

Program:

public class Main
{
public static void main(String args[])
{
//value of centimeter declared
double centimeter = 1;
//value of micrometer declared
double micrometer = 1;

//converting centimeter to micrometer
double micmt = centimeter * 10000;
//converting micrometer to centimeter
double cm = micrometer / 10000;
//printing result
System.out.println("Value of "+centimeter+" centimeter in micrometer: "+ micmt);
System.out.println("Value of "+micrometer+" micrometer in centimeter: "+ cm);
}
}
Output:

Value of 1.0 centimeter in micrometer: 10000.0
Value of 1.0 micrometer in centimeter: 1.0E-4

### Method-2: Java Program to Convert Centimeter to Micrometer and Micrometer to Centimeter By Using User Input Value

Approach:

• Take user input of Centimeter and Micrometer value.
• Then convert Centimeter to Micrometer and Micrometer to Centimeter by using the formula.
• Print result.

Program:

import java.util.*;
public class Main
{
public static void main(String args[])
{
//Scanner class object created
Scanner sc=new Scanner(System.in);
//Taking the value input of double variable centimeter
System.out.println("Enter value of centimeter: ");
double centimeter = sc.nextDouble();
//Taking the value input of double variable micrometer
System.out.println("Enter value of micrometer: ");
double micrometer = sc.nextDouble();

//converting centimeter to micrometer
double micmt = centimeter * 10000;
//converting micrometer to centimeter
double cm = micrometer / 10000;
//printing result
System.out.println("Value of "+centimeter+" centimeter in micrometer: "+ micmt);
System.out.println("Value of "+micrometer+" micrometer in centimeter: "+ cm);
}
}
Output:

Enter value of centimeter:
1000
Enter value of micrometer:
1000
Value of 1000.0 centimeter in micrometer: 1.0E7
Value of 1000.0 micrometer in centimeter: 0.1


### Method-3: Java Program to Convert Centimeter to Micrometer and Micrometer to Centimeter By Using User Defined Method

Approach:

• Take user input of Centimeter and Micrometer value.
• Call a user defined method by passing Centimeter and Micrometer value as parameter.
• Inside method convert Centimeter to Micrometer and Micrometer to Centimeter by using the formula.
• Print result.

Program:

import java.util.*;
public class Main
{
public static void main(String args[])
{
//Scanner class object created
Scanner sc=new Scanner(System.in);
//Taking the value input of double variable centimeter
System.out.println("Enter value of centimeter: ");
double centimeter = sc.nextDouble();
//Taking the value input of double variable micrometer
System.out.println("Enter value of micrometer: ");
double micrometer = sc.nextDouble();
//calling user defined method convert()
convert(centimeter, micrometer);
}

//convert() method to convert centimeter to micrometer and vice versa
public static void convert(double centimeter, double micrometer)
{
//converting centimeter to micrometer
double micmt = centimeter * 10000;
//converting micrometer to centimeter
double cm = micrometer / 10000;
//printing result
System.out.println("Value of "+centimeter+" centimeter in micrometer: "+ micmt);
System.out.println("Value of "+micrometer+" micrometer in centimeter: "+ cm);
}
}
Output:

Enter value of centimeter:
200000
Enter value of micrometer:
500000
Value of 200000.0 centimeter in micrometer: 2.0E9
Value of 500000.0 micrometer in centimeter: 50.0


Have you mastered basic programming topics of java and looking forward to mastering advanced topics in a java programming language? Go with these ultimate Advanced java programs examples with output & achieve your goal in improving java coding skills.

Related Java Programs: