# Java Program to Convert Foot to Millimeter and Millimeter to Foot

In the previous article, we have discussed about Java Program to Convert Foot to Meter and Meter to Foot

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

## Java Program to Convert Foot to Millimeter and Millimeter to Foot

Before jumping into the program let’s know the relationship between Foot and Millimeter and how we can convert Foot to Millimeter and vice versa.

Generally Foot and Millimeter are used as unit in case of length/distance measurement.

1 Foot = 304.8 Millimeter
1 Millimeter =  0.00328084 Foot

Formula to convert Millimeter to Foot.

Foot = Millimeter * 0.00328084

Formula to convert Foot to Millimeter.

Millimeter  = Foot * 304.8

Let’s see different ways to convert Foot to Millimeter and Millimeter to Foot.

### Method-1: Java Program to Convert Foot to Millimeter and Millimeter to Foot By Using Static Input Value

Approach:

• Declare Foot and Millimeter value.
• Then convert Foot to Millimeter and Millimeter to Foot 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 millimeter declared
double millimeter = 1;
//value of foot declared
double foot = 1;

//converting foot to meter
double mm = foot * 304.8;
//converting millimeter to foot
double f = millimeter * 0.00328084;
//printing result
System.out.println("Value of "+millimeter+" millimeter in foot: "+ f);
System.out.println("Value of "+foot+" foot in millimeter: "+ mm);
}
}
Output:

Value of 1.0 millimeter in foot: 0.00328084
Value of 1.0 foot in millimeter: 304.8

### Method-2: Java Program to Convert Foot to Millimeter and Millimeter to Foot By Using User Input Value

Approach:

• Take user input of Foot and Millimeter value.
• Then convert Foot to Millimeter and Millimeter to Foot 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 millimeter
System.out.println("Enter value of millimeter: ");
double millimeter = sc.nextDouble();
//Taking the value input of double variable foot
System.out.println("Enter value of foot: ");
double foot = sc.nextDouble();

//converting foot to meter
double mm = foot * 304.8;
//converting millimeter to foot
double f = millimeter * 0.00328084;
//printing result
System.out.println("Value of "+millimeter+" millimeter in foot: "+ f);
System.out.println("Value of "+foot+" foot in millimeter: "+ mm);
}
}
Output:

Enter value of millimeter:
666
Enter value of foot:
6
Value of 666.0 millimeter in foot: 2.18503944
Value of 6.0 foot in millimeter: 1828.8000000000002


### Method-3: Java Program to Convert Foot to Millimeter and Millimeter to Foot By Using User Defined Method

Approach:

• Take user input of Foot and Millimeter value.
• Call a user defined method by passing Foot and Millimeter value as parameter.
• Inside method convert Foot to Millimeter and Millimeter to Foot 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 millimeter
System.out.println("Enter value of millimeter: ");
double millimeter = sc.nextDouble();
//Taking the value input of double variable foot
System.out.println("Enter value of foot: ");
double foot = sc.nextDouble();
//calling user defined method convert()
convert(millimeter, foot);
}

//convert() method to convert millimeter to foot and vice versa
public static void convert(double millimeter, double foot)
{
//converting foot to meter
double mm = foot * 304.8;
//converting millimeter to foot
double f = millimeter * 0.00328084;
//printing result
System.out.println("Value of "+millimeter+" millimeter in foot: "+ f);
System.out.println("Value of "+foot+" foot in millimeter: "+ mm);
}
}
Output:

Enter value of millimeter:
5990
Enter value of foot:
78
Value of 5990.0 millimeter in foot: 19.6522316
Value of 78.0 foot in millimeter: 23774.4


Provided list of Simple Java Programs is specially designed for freshers and beginners to get familiarize with the concepts of Java programming language and become pro in coding.

Related Java Programs: