Area Of Rectangle Example Java Program

Definition

The area of the rectangle is the length multiplied by the width.

Formula

The area of a rectangle is written as,
A=l*b

where,
A=Area
l=length
b=breadth

Area Of Rectangle Example Program

import java.util.Scanner;

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

Sample Output

Output is:
Enter the length: 4
Enter the breadth: 6
The area of the rectangle is:24