Write a java program to calculate area of rectangle by passing and returning object as a parameter.



Source Code:-

import java.io.*;

class rect

{

          rect(double n,double m)

          {

                   double l,b,area;

                   l=n;

                   b=m;

                   area=l*b;

                   System.out.println("Area of Rectangle :"+area);

          }

          public static void main(String arg[] )

          {

                   new rect(10.0,20.0);

          }

}
Output :-

Comments

Popular posts from this blog

Write a Java code to input height (in inches) and convert it into feet and inches.

Design an AWT application to calculate the factorial of a number.

Design an AWT application to check whether the number entered in textbox is prime or not.