allintitle:Java program to find area of rectangle using function code example

Example: Java program to find area of rectangle using function

import java.util.Scanner;
public class RectangleAreaUsingFunction
{
   public static void areaRectangle(double width, double height)
   {
      double area;
      area = width * height;
      System.out.println("Area of rectangle : " + area);
   }
   public static void main(String[] args)
   {
      double width, height;
      Scanner sc = new Scanner(System.in);
      System.out.println("Please enter length of rectangle : ");
      width = sc.nextDouble();
      System.out.println("Please enter width of rectangle : ");
      height = sc.nextDouble();
      areaRectangle(width, height);
      sc.close();
   }
}

Tags:

Java Example