Write a program in java to find out area of rectangle and volume of cuboid using inheritance?

import java.util.Scanner;

class Find

{

                int length,width,height;

                public void area()

                {

                                System.out.println("Area of Rectangle "+length*width);

                }

                public void volume()

                {

                                System.out.println("Volume of Cuboid "+length*width*height);

                }

                public void input()

                {

                                Scanner scan=new Scanner(System.in);

                                System.out.print("Enter Length ");

                                length=scan.nextInt();

                                System.out.print("Enter Width ");

                                width=scan.nextInt();

                                System.out.print("Enter Height ");

                                height=scan.nextInt();

                }

}

class FindOut extends Find

{

                public static void main(String arg[])

                {

                                FindOut f=new FindOut();

                                f.input();

                                f.area();

                                f.volume();

                }

}

Find Out Area of Rectangle and Volume of Cuboid using Inheritance.PNG

, , , , , , , ,

Leave a Reply