Java Program to find area of Rectangle

Get length and breadth of rectangle and find area of rectangle

Sample Input 1:

4 5

Sample Output 1:

20

Try your Solution

Strongly recommended to Solve it on your own, Don't directly go to the solution given below.

public class Hello { public static void main(String args[]) { //Write your code here } }

Program or Solution

				
			
					
import java.util.*;
class Rectangle
{
 
       public static void main(String args[])
       {
 
             int length,breadth,area;
 		   Scanner sc=new Scanner(System.in);
             System.out.println("Get length and breadth of Rectangle and find area of Rectangle");
             System.out.println("Enter The length :");
             length=sc.nextInt();
             System.out.println("Enter The breadth :");
             breadth=sc.nextInt();
             area=length*breadth;
             System.out.println("The Output 1 Is:\n"+area);

       }

}
			
				
			

Program Explanation

Get length and breadth of a rectangle (using scanner class) Calculate area by multiplying length and breadth (area = length * breadth) print area (using system.out.println)

Comments