Java Program to Convert Acer to Square Inch and Square Inch to Acer

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

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

Java Program to Convert Acer to Square Inch and Square Inch to Acer

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

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

1 Acer =  6.273e+6 Square Inch
1 Square Inch  =  1.59423e-7 Acer

Formula to convert acer to square inch.

Square Inch  = Acer * 6.273e+6

Formula to convert square inch to acer .

Acer = Square Inch  / 6.273e+6

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

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

Approach:

  • Declare user input of acer and square inch value.
  • Then convert acer to square inch and square inch 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 inch declared  
        double squareinch = 1;
        
        //converting square inch to acer value
        double a = squareinch / 6.273e+6;
        //converting acer to square inch value
        double si = acer * 6.273e+6;
        //printing result
        System.out.println("Value of "+squareinch+" square inch in acer: "+ a);   
        System.out.println("Value of "+acer+" acer in square inch: "+ si);   
   }
}
Output:

Value of 1.0 square inch in acer: 1.5941335883947074E-7
Value of 1.0 acer in square inch: 6273000.0

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

Approach:

  • Take user input of acer and square inch value.
  • Then convert acer to square inch and square inch 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 squareinch
        System.out.println("Enter value of square inch: ");  
        double squareinch = sc.nextDouble();
        
        //converting square inch to acer value
        double a = squareinch / 6.273e+6;
        //converting acer to square inch value
        double si = acer * 6.273e+6;
        //printing result
        System.out.println("Value of "+squareinch+" square inch in acer: "+ a);   
        System.out.println("Value of "+acer+" acer in square inch: "+ si);   
   }
}
Output:

Enter value of acer: 
5
Enter value of square inch: 
500000
Value of 500000.0 square inch in acer: 0.07970667941973537
Value of 5.0 acer in square inch: 3.1365E7

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

Approach:

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

Enter value of acer: 
3
Enter value of square inch: 
3000000
Value of 3000000.0 square inch in acer: 0.4782400765184122
Value of 3.0 acer in square inch: 1.8819E7

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

Related Java Programs: