Java Program to find area of Rectangle

Description

Get length and breadth of rectangle and find area of rectangle
Input 1:
4 5
Output1:
20

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 Input 1:");
             length=sc.nextInt();
             System.out.println("Enter Input 2:");
             breadth=sc.nextInt();
             area=length*breadth;
             System.out.println("The Output 1 Is:\n"+area);

       }

}

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)
Ramesh P Natarajan

Author - Ramesh P Natarajan

Learner, Professor, Technology Trainer, Software Developer and Content Marketer, very much passionate in the field of Software Application Development, Machine Learning and Search Engine Optimization.

Write to: admin@decodeschool.com





Interesting Pattern Programs: for more Patterns

Input:
5
Output:
*
**
***
****
*****
****
***
**
*Solution
Input:
5
Output:
    *
   ***
  *****
 *******
*********
 *******
  *****
   ***
    *Solution
Input:
5
Output:
*        *
**      **
***    ***
****  ****
**********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********
**** ****
***   ***
**     **
*       *Solution
Input:
5
Output:
*********
 *******
  *****
   ***
    *
   ***
  *****
 *******
*********Solution