Method In Java Program
Program Name:- method.java
import java.io.*;
class circle
{
double radius;
final double pi=3.14;
circle(double r)
{
radius=r;
}
double area()
{
return pi*radius*radius;
}
double circum()
{
return 2*pi*radius;
}
}
class cylinder extends circle
{
double hight;
cylinder(double r,double h)
{
super(r);
hight=h;
}
double area()
{
return circum()*hight;
}
double volume()
{
return pi*radius*hight;
}
}
class method
{
public static void main(String args[])
{
double area,area1,sectionarea,surfacearea,volume;
circle cir=new circle(5.5);
cylinder cy=new cylinder(3.2,12.5);
area=cir.area();
area1=cir.circum();
System.out.println("\nArea of the circle of radius "+cir.radius+"\t:"+area);
System.out.println("\nCircum ference of a circle\t:"+area1);
System.out.println("\nCalculation for cylinder of radius "+cy.radius+" and height "+cy.hight);
surfacearea=cy.area();
volume=cy.volume();
System.out.println("\nSurface area\t"+surfacearea);
System.out.println("\nVolume \t"+volume);
}
}
No comments:
Post a Comment