Java Programs

Please click on 1-2 Ads to keep this website's Study Material FREE and regularly Updated.

Program 1: Write a Java program to calculate the area of the rectangle.

Rectangle.java

import java.util.Scanner;

public class Rectangle
{
	public static void main(String[] args)
	{		
		//Declaring Variables	
		int length;
		int breadth;
		int Area;

		Scanner s =new Scanner(System.in);

		System.out.println("Enter the length of the Rectangle");
		length=s.nextInt();

		System.out.println("Enter the breadth of the Rectangle");
		breadth=s.nextInt();

		Area=length*breadth;

		System.out.println("Area: "+Area);		
	}
}



If you have any suggestion or found any error in the above program, then do let us know at [email protected] or just comment below.