Q:

Java program to find Area of Rectangle

0

Java program to find Area of Rectangle

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Area of Rectangle using Java program

//Java program to find Area of Rectangle.
 
import java.util.*;
 
public class AreaRectangle{
 
     public static void main(String []args){
        double length,width,area;
         
        Scanner sc=new Scanner(System.in);
         
        //Read Length and Width of Rectangle
        System.out.print("Enter length: ");
        length=sc.nextDouble();
        System.out.print("Enter width: ");
        width=sc.nextDouble();
         
        //Calculate Area 
        area= length*width;
         
        //Print Result
        System.out.println("Area of Rectangle: " + area);    
         
     }
}

Output

 
    me@linux:~$ javac AreaRectangle.java
    me@linux:~$ java AreaRectangle

    Enter length: 10.2
    Enter width: 20.3 
    Area of Rectangle: 207.06

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Core Java Example programs for Beginners and Professionals

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Java program to Calculate Area of a Circle... >>
<< Java program to find Area of Triangle...