# Java Programming | Area conversion

Introduction

This is a tutorial for conversion of area from one unit to other unit. The program takes input from user and converts it and prints it. The program is extendable. Go enjoy the program. Lets Begin….

Program for conversion of area from meter sq. to centimeter sq. in java.

``````
//import Scanner as we require it.
import java.util.Scanner;

// the name of our class its public
public class AreaConversion {
//void main
public static void main (String[] args)
{
//declare float
float to,from;
//print message
System.out.println("Enter Area in meter sq.:");
//Take input
Scanner input = new Scanner(System.in);
//calculate
from = input.nextFloat();
to = from*10000;
//print the average
System.out.println("Area in centimeter sq. = "+to);
}
}
``````

Output

Enter Area in meter sq.:
0.987
Area in centimeter sq. = 9870.0

How it works

1. The program prints the message to enter area.
2. The user enters area.
3. Area is converted.
4. The converted area is printed.

Extending it

The Program can be extended by adding more unit to conversion and by adding their Conversion formula for other unit and more variables can be added to program to convert multiple areas. Like wise you can also use following unit for conversion :-

• centimeter sq.
• meter sq.
• acre
• feet sq.
• hectare
• inch sq.
• mile sq.
• yard sq.

Explanation.

1. Import the Scanner.
2. Declare the class as public
3. Add the void main function
4. Add system.out.println() function with the message to enter area.
5. Declare input as Scanner.
6. Take the area and save it in variable.
7. Convert area and save it in other variable.
8. Add system.out.println() function to print the converted area.

At the end.

You learnt creating the Java program for Area conversion. So now enjoy the program.

Please comment on the post and share it.
And like it if you liked.

Sharing options: