Area Of Square Example Java Program

Definition

In classical times, the second power was described in terms of the area of a square, as in the above formula. This led to the use of the term square to mean raising to the second power. Thus the area of the square is twice the length of the square.

Formula

The area of a square is written as,
A=s^2

where,
A=Area
s=side of the square

Area Of Square Example Program

import java.util.Scanner;
class AreaOfSquare{
	static Scanner in = new Scanner(System.in);
	public static void main(String args[]){
		System.out.print("Enter the length: ");
		int length = in.nextInt();
		int area=length*length;
		System.out.println( "The area of the square is:"+area) ;
	}
}

Sample Output

Output is:
Enter the length: 4
The area of the square is:16