Chapter: Miscellaneous Last Updated: 10-08-2016 16:50:38 UTC

Program:

` ````
/* ............... START ............... */
import java.util.Scanner;
public class JavaAreaOfRectangle {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the length of Rectangle:");
double length = scanner.nextDouble();
System.out.println("Enter the width of Rectangle:");
double width = scanner.nextDouble();
// Area = length*width;
double area = length * width;
System.out.println("Area of Rectangle is:" + area);
}
}
/* ............... END ............... */
```

Output

Enter the length of Rectangle: 10 Enter the width of Rectangle: 20 Area of Rectangle is:200.0

Notes:

- The rectangle is a quadrilateral, which means it has four sides. Its opposite sides are equal in length, so the sides along its length are equal, and the sides along its width are equal as well. If one side of the rectangle is 10, for example, then the opposite side's length will also be 10.
- Also, every square is a rectangle, but not all rectangles are squares. So treat squares like rectangles in terms of finding its area.

Tags

Calculate Area Of Rectangle, Java