//Area of Rectangle class Rectangle { void area(double l,double b) { double ar=l*b; System.out.println("Area of the rectangle is:"+ar); } } class RectangleMain { public static void main(String arg[]) { Rectangle r = new Rectangle(); double len,br; System.out.println("Enter length & breadth :"); len = Integer.parseInt(System.console().readLine()); br = Integer.parseInt(System.console().readLine()); r.area(len,br); } }
Output: |
---|
Enter length & breadth : |
2 |
4 |
Area of the rectangle is:8.0 |