# Java Program to Convert Acer to Square Kilometer and Square Kilometer to Acer

In the previous article, we have discussed about Java Program to Convert Acer to Square Yard and Square Yard to Acer

In this article we will see how to convert acer to square kilometer and square kilometer to acer by using Java programming language.

## Java Program to Convert Acer to Square Kilometer and Square Kilometer to Acer

Before jumping into the program let’s know the relationship between acer and square kilometer and how we can convert acer to square kilometer and vice-versa.

Generally acer and square kilometer are used as unit in case of land measurement.

1 Acer =  0.00404686 Square Kilometer
1 Square Kilometer  =  247.105 Acer

Formula to convert acer to square kilometer.

Square Kilometer  = Acer * 0.00404686

Formula to convert square Kilometer to acer .

Acer = Square Kilometer  * 247.105

Let’s see different ways to convert acer to square kilometer and square kilometer to acer.

### Method-1: Java Program to Convert Acer to Square Kilometer and Square Kilometer to Acer By Using Static Input Value

Approach:

• Declare user input of acer and square kilometer value.
• Then convert acer to square kilometer and square kilometer to acer by using the formula.
• Print result.

Program:

public class Main
{
public static void main(String args[])
{
//value of acer declared
double acer = 1;
//value of square kilometer declared
double squarekilometer = 1;

//converting square kilometer to acer value
double a = squarekilometer * 247.105;
//converting acer to square kilometer value
double skm = acer * 0.00404686;
//printing result
System.out.println("Value of "+squarekilometer+" square kilometer in acer: "+ a);
System.out.println("Value of "+acer+" acer in square kilometer: "+ skm);
}
}
Output:

Value of 1.0 square kilometer in acer: 247.105
Value of 1.0 acer in square kilometer: 0.00404686

### Method-2: Java Program to Convert Acer to Square Kilometer and Square Kilometer to Acer By Using User Input Value

Approach:

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

//converting square kilometer to acer value
double a = squarekilometer * 247.105;
//converting acer to square kilometer value
double skm = acer * 0.00404686;
//printing result
System.out.println("Value of "+squarekilometer+" square kilometer in acer: "+ a);
System.out.println("Value of "+acer+" acer in square kilometer: "+ skm);
}
}
Output:

Enter value of acer:
145000
Enter value of square kilometer:
5
Value of 5.0 square kilometer in acer: 1235.5249999999999
Value of 145000.0 acer in square kilometer: 586.7947

### Method-3: Java Program to Convert Acer to Square Kilometer and Square Kilometer to Acer By Using User Defined Method

Approach:

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

//convert() method to convert acer to square kilometer and vice versa
public static void convert(double acer, double squarekilometer)
{

//converting square kilometer to acer value
double a = squarekilometer * 247.105;
//converting acer to square kilometer value
double skm = acer * 0.00404686;
//printing result
System.out.println("Value of "+squarekilometer+" square kilometer in acer: "+ a);
System.out.println("Value of "+acer+" acer in square kilometer: "+ skm);
}
}
Output:

Enter value of acer:
1450
Enter value of square kilometer:
6.8
Value of 6.8 square kilometer in acer: 1680.3139999999999
Value of 1450.0 acer in square kilometer: 5.867947

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: