In the previous article we have discussed about Java Program to Convert Centimeter to Inch and Inch to Centimeter
In this article we will see how to convert Millimeter to Micrometer and Micrometer to Millimeter by using Java programming language.
Java Program to Convert Millimeter to Micrometer and Micrometer to Millimeter
Before jumping into the program let’s know the relationship between Millimeter and Micrometer and how we can convert Millimeter to Micrometer and vice versa.
Generally Millimeter is used to measure very small length mainly we use to measure visible scale distances and Micrometer is used to measure very very small length as compared to Millimeter.
1 Millimeter = 1000 Micrometer 1 Micrometer = Millimeter
Formula to convert Millimeter to Micrometer.
Micrometer = Millimeter * 1000
Formula to convert Micrometer to Millimeter.
Millimeter = Micrometer / 1000
Let’s see different ways to convert Millimeter to Micrometer and Micrometer to Millimeter.
Method-1: Java Program to Convert Millimeter to Micrometer and Micrometer to Millimeter By Using Static Input Value
Approach:
- Declare Millimeter and Micrometer value.
- Then convert Millimeter to Micrometer and Micrometer to Millimeter 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); //value of micrometer declared double micrometer = 1; //value of millimeter declared double millimeter = 1; //converting millimeter to micrometer double um = millimeter*1000; //converting micrometer to millimeter double mm = micrometer/1000; //printing result System.out.println("Value of "+micrometer+" micrometer in millimeter: "+ mm); System.out.println("Value of "+millimeter+" millimeter in micrometer: "+ um); } }
Output: Value of 1.0 micrometer in millimeter: 0.001 Value of 1.0 millimeter in micrometer: 1000.0
Method-2: Java Program to Convert Millimeter to Micrometer and Micrometer to Millimeter By Using User Input Value
Approach:
- Take user input of Millimeter and Micrometer value.
- Then convert Millimeter to Micrometer and Micrometer to Millimeter 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 micrometer System.out.println("Enter value of micrometer: "); double micrometer = sc.nextDouble(); //Taking the value input of double variable millimeter System.out.println("Enter value of millimeter: "); double millimeter = sc.nextDouble(); //converting millimeter to micrometer double um = millimeter*1000; //converting micrometer to millimeter double mm = micrometer/1000; //printing result System.out.println("Value of "+micrometer+" micrometer in millimeter: "+ mm); System.out.println("Value of "+millimeter+" millimeter in micrometer: "+ um); } }
Output: Enter value of micrometer: 8900 Enter value of millimeter: 150 Value of 8900.0 micrometer in millimeter: 8.9 Value of 150.0 millimeter in micrometer: 150000.0
Method-3: Java Program to Convert Millimeter to Micrometer and Micrometer to Millimeter By Using User Defined Method
Approach:
- Take user input of Millimeter and Micrometer value.
- Call a user defined method by passing Millimeter and Micrometer value as parameter.
- Inside method convert Millimeter to Micrometer and Micrometer to Millimeter 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 micrometer System.out.println("Enter value of micrometer: "); double micrometer = sc.nextDouble(); //Taking the value input of double variable millimeter System.out.println("Enter value of millimeter: "); double millimeter = sc.nextDouble(); //calling user defined method convert() convert(micrometer, millimeter); } //convert() method to convert micrometer to millimeter and vice versa public static void convert(double micrometer, double millimeter) { //converting millimeter to micrometer double um = millimeter*1000; //converting micrometer to millimeter double mm = micrometer/1000; //printing result System.out.println("Value of "+micrometer+" micrometer in millimeter: "+ mm); System.out.println("Value of "+millimeter+" millimeter in micrometer: "+ um); } }
Output: Enter value of micrometer: 6000 Enter value of millimeter: 40 Value of 6000.0 micrometer in millimeter: 6.0 Value of 40.0 millimeter in micrometer: 40000.0
The best and excellent way to learn a java programming language is by practicing Simple Java Program Examples as it includes basic to advanced levels of concepts.
Related Java Programs: