In the previous article, we have discussed about Java Program to Convert Byte to Kilobyte
In this article we will see how to convert acer to square foot and square foot to acer by using Java programming language.
Java Program to Convert Acer to Square foot and Square foot to Acer
Before jumping into the program let’s know the relationship between acer and square foot and how we can convert acer to square foot and vice-versa.
Generally acer and square feet are used as unit in case of land measurement.
1 Acer = 43560 Square feet 1 Square feet = 2.2957e-5 Acer
Formula to convert acer to square feet.
Square feet = Acer * 43560
Formula to convert square feet to acer .
Acer = Square feet * 2.2957e-5
Let’s see different ways to convert acer to square foot and square foot to acer
Method-1: Java Program to Convert Acer to Square foot and Square foot to Acer By Using Static Input Value
Approach:
- Declare user input of acer and square feet value.
- Then convert acer to square feet and square feet 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 feet declared double squarefeet = 1; //calculating acer value double a = squarefeet * 2.2957e-5; //calculating square feet value double sft = acer * 43560; //printing result System.out.println("Value of "+squarefeet+" square feet in acer: "+ a); System.out.println("Value of "+acer+" acer in square feet: "+ sft); } }
Output: Value of 1.0 square feet in acer: 2.2957E-5 Value of 1.0 acer in square feet: 43560.0
Method-2: Java Program to Convert Acer to Square foot and Square foot to Acer By Using User Input Value
Approach:
- Take user input of acer and square feet value.
- Then convert acer to square feet and square feet 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 squarefeet System.out.println("Enter value of square feet: "); double squarefeet = sc.nextDouble(); //calculating acer value double a = squarefeet * 2.2957e-5; //calculating square feet value double sft = acer * 43560; //printing result System.out.println("Value of "+squarefeet+" square feet in acer: "+ a); System.out.println("Value of "+acer+" acer in square feet: "+ sft); } }
Output: Enter value of acer: 2 Enter value of square feet: 90000 Value of 90000.0 square feet in acer: 2.0661300000000002 Value of 2.0 acer in square feet: 87120.0
Method-3: Java Program to Convert Acer to Square foot and Square foot to Acer By Using User Defined Method
Approach:
- Take user input of acer and square feet value.
- Call a user defined method by passing acer and square feet value as parameter.
- Inside method convert acer to square feet 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 squarefeet System.out.println("Enter value of square feet: "); double squarefeet = sc.nextDouble(); //calling user defined method convert() convert(acer, squarefeet); } //convert() method to convert acer to squarefeet and vice versa public static void convert(double acer, double squarefeet) { //calculating acer value double a = squarefeet * 2.2957e-5; //calculating squarefeet value double sft = acer * 43560; //printing result System.out.println("Value of "+squarefeet+" square feet in acer: "+ a); System.out.println("Value of "+acer+" acer in square feet: "+ sft); } }
Output: Enter value of acer: 5 Enter value of square feet: 88000 Value of 88000.0 square feet in acer: 2.020216 Value of 5.0 acer in square feet: 217800.0
Guys who are serious about learning the concepts of the java programming language should practice this list of programs in java and get a good grip on it for better results in exams or interviews.
Related Java Programs: