Java Program To Calculate Area Of Rectangle - Java Program Example

Write Java Program To  Calculate Area Of Rectangle. In This Post We Share A Java Program Code For Calculate  Area Of Rectangle Entered By User And Show Output On Screen After Compile Program.


package com.androidpro.in;

import
java.io.BufferedReader;
import
java.io.InputStreamReader;
import
java.util.Scanner;

public class
Main {

   
public static void main(String[] args)
    {
        Scanner scanner =
new Scanner(System.in);
       
System.out.println("Enter the length of Rectangle:");
        double
length = scanner.nextDouble();
       
System.out.println("Enter the width of Rectangle:");
        double
width = scanner.nextDouble();
       
//Area = length*width;
       
double area = length * width;
       
System.out.println("Area of Rectangle is:" + area);
   
}


}

 

Output

Enter the length of Rectangle:

12

Enter the width of Rectangle:

32

Area of Rectangle is:384.0

Process finished with exit code 0

Post a Comment

0 Comments