Chapter: Miscellaneous Last Updated: 12-08-2016 18:55:38 UTC

Program:

` ````
/* ............... START ............... */
import java.util.Scanner;
public class JavaAreaOfSquare {
public static void main(String[] args) {
System.out.println("Enter Side of Square:");
// Capture the user's input
Scanner scanner = new Scanner(System.in);
// Storing the captured value in a variable
double side = scanner.nextDouble();
// Area of Square = side*side
double area = side * side;
System.out.println("Area of Square is: " + area);
}
}
/* ............... END ............... */
```

Output

Enter Side of Square: 40 Area of Square is: 1600.0

Notes:

- In geometry, a square is a regular quadrilateral, which means that it has four equal sides and four equal angles (90-degree angles, or right angles).[1] It can also be defined as a rectangle in which two adjacent sides have equal length.
- The area of a square is given by the formula area=width × height.

Tags

Calculate Area Of Square, Java