Java program to find the area of a rectangle


Area of a rectangle is the product of its length and breadth. Therefore, to calculate the area of a rectangle

  • Get the length of the rectangle form the user.
  • Get the breadth of the rectangle form the user.
  • Calculate their product.
  • Print the product.

Example

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

Output

Enter the length of the rectangle ::
56
Enter the breadth of the rectangle ::
48
Area of the rectangle is ::2688

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 13-Mar-2020

8K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements