Java Program to Find the Area of Rectangle - The Coding Shala

Home >> Java Programs >> Area of Rectangle

 In this post, we will learn how to write a Java Program to Find the Area of a Rectangle.

Java Program to Find the Area of Rectangle

The length and width of a rectangle are given to us, find the total area of the rectangle using a Java Program.

Area of Rectangle = length * width

Example 1:
Input: length = 2
           width = 8
Output: Area = 16

Java Program

// Java program to Find Area of Rectangle

import java.util.Scanner;

public class Main {
	public static void main(String[] args) { 
		Scanner sc = new Scanner(;
		// take length input
		System.out.println("Enter the length of rectangle");
		double length = sc.nextDouble();
		// take width input
		System.out.println("Enter the width of rectangle");
		double width = sc.nextDouble();		
		// calculate the area
		// area = length * width
		double area = length * width;
		System.out.println("Area of Rectangle is: " + area);


Enter the length of rectangle
Enter the width of rectangle
Area of Rectangle is: 16.0

Other Posts You May Like
Please leave a comment below if you like this post or found some errors, it will help me to improve my content.


Popular Posts from this Blog

Shell Script to find sum, product and average of given numbers - The Coding Shala

Single Number 3 LeetCode Solution - The Coding Shala

LeetCode - Number of Good Pairs Solution - The Coding Shala

Shell Script to Create a Simple Calculator - The Coding Shala

Java Method Overloading - The Coding Shala