# Java Program to Convert Foot to Nautical Mile and Nautical Mile to Foot

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

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

## Java Program to Convert Foot to Nautical Mile and Nautical Mile to Foot

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

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

1 Foot = 0.000164579 Nautical Mile
1 Nautical Mile = 6076.12 Feet

Formula to convert Nautical Mile to Foot.

Foot = Nautical Mile * 6076.12

Formula to convert Foot to Nautical Mile.

Nautical Mile = Foot * 0.000164579

Let’s see different ways to convert Foot to Nautical Mile and Nautical Mile to Foot.

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

Approach:

• Declare Foot and Nautical Mile value.
• Then convert Foot to Nautical Mile and Nautical Mile to Foot by using the formula.
• Print result.

Program:

public class Main
{
public static void main(String args[])
{
//value of foot declared
double foot = 1;
//value of Nautical Mile declared
double nauticalMile = 1;

//converting foot to Nautical Mile
double nm = foot * 0.000164579;
//converting Nautical Mile to foot
double f = nauticalMile * 6076.12;
//printing result
System.out.println("Value of "+nauticalMile+" Nautical Mile in foot: "+ f);
System.out.println("Value of "+foot+" foot in Nautical Mile: "+ nm);
}
}
Output:

Value of 1.0 Nautical Mile in foot: 6076.12
Value of 1.0 foot in Nautical Mile: 1.64579E-4

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

Approach:

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

//converting foot to Nautical Mile
double nm = foot * 0.000164579;
//converting Nautical Mile to foot
double f = nauticalMile * 6076.12;
//printing result
System.out.println("Value of "+nauticalMile+" Nautical Mile in foot: "+ f);
System.out.println("Value of "+foot+" foot in Nautical Mile: "+ nm);
}
}
Output:

Enter value of Nautical Mile:
894
Enter value of foot:
90009
Value of 894.0 Nautical Mile in foot: 5432051.28
Value of 90009.0 foot in Nautical Mile: 14.813591211


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

Approach:

• Take user input of Foot and Nautical Mile value.
• Call a user defined method by passing Foot and Nautical Mile value as parameter.
• Inside method convert Foot to Nautical Mile and Nautical Mile 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 Nautical Mile
System.out.println("Enter value of Nautical Mile: ");
double nauticalMile = 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(nauticalMile, foot);
}

//convert() method to convert Nautical Mile to foot and vice versa
public static void convert(double nauticalMile, double foot)
{

//converting foot to Nautical Mile
double nm = foot * 0.000164579;
//converting Nautical Mile to foot
double f = nauticalMile * 6076.12;
//printing result
System.out.println("Value of "+nauticalMile+" Nautical Mile in foot: "+ f);
System.out.println("Value of "+foot+" foot in Nautical Mile: "+ nm);
}
}
Output:

Enter value of Nautical Mile:
5
Enter value of foot:
99999
Value of 5.0 Nautical Mile in foot: 30380.6
Value of 99999.0 foot in Nautical Mile: 16.457735421000002


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: