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

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

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

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

1 Acer = 4840 Square Yard 1 Square Yard = 0.000206612 Acer

Formula to convert acer to square yard.

Square Yard = Acer * 4840

Formula to convert square yard to acer .

Acer = Square Yard * 0.000206612

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

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

**Approach:**

- Declare user input of acer and square yard value.
- Then convert acer to square yard and square yard 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 yard declared double squareyard = 1; //converting square yard to acer value double a = squareyard * 0.000206612; //converting acer to square yard value double sy = acer * 4840; //printing result System.out.println("Value of "+squareyard+" square yard in acer: "+ a); System.out.println("Value of "+acer+" acer in square yard: "+ sy); } }

Output: Value of 1.0 square yard in acer: 2.06612E-4 Value of 1.0 acer in square yard: 4840.0

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

**Approach:**

- Take user input of acer and square yard value.
- Then convert acer to square yard and square yard 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 squareyard System.out.println("Enter value of square yard: "); double squareyard = sc.nextDouble(); //converting square yard to acer value double a = squareyard * 0.000206612; //converting acer to square yard value double sy = acer * 4840; //printing result System.out.println("Value of "+squareyard+" square yard in acer: "+ a); System.out.println("Value of "+acer+" acer in square yard: "+ sy); } }

Output: Enter value of acer: 5 Enter value of square yard: 400000 Value of 400000.0 square yard in acer: 82.6448 Value of 5.0 acer in square yard: 24200.0

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

**Approach:**

- Take user input of acer and square yard value.
- Call a user defined method by passing acer and square yard value as parameter.
- Inside method convert acer to square yard 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 squareyard System.out.println("Enter value of square yard: "); double squareyard = sc.nextDouble(); //calling user defined method convert() convert(acer, squareyard); } //convert() method to convert acer to square yard and vice versa public static void convert(double acer, double squareyard) { //converting square yard to acer value double a = squareyard * 0.000206612; //converting acer to square yard value double sy = acer * 4840; //printing result System.out.println("Value of "+squareyard+" square yard in acer: "+ a); System.out.println("Value of "+acer+" acer in square yard: "+ sy); } }

Output: Enter value of acer: 5.5 Enter value of square yard: 555555 Value of 555555.0 square yard in acer: 114.78432966 Value of 5.5 acer in square yard: 26620.0

Are you new to the java programming language? We recommend you to ace up your practice session with these Basic Java Programs Examples