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

LeetCode - Crawler Log Folder Solution - The Coding Shala

Richest Customer Wealth LeetCode Solution - The Coding Shala

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

First Unique Character in a String Java - The Coding Shala

Add two numbers in Scala - The Coding Shala