import java.util.Scanner;
import java.util.*;
interface supz
{final double
pi=3.14; public void display();}
class Data
{
double r;
public void gdata()
{
System.out.println("Enter Radius");
Scanner s = new Scanner(System.in);
r=s.nextFloat();
}
}
class Area
extends Data
{
double area;
public void aclc()
{area = r*r*3.14;}
public void display()
{System.out.println("Area of Circle=
"+area);}
}
class Volume extends Area implements supz
{
double v;
public void vclc()
{v=(4*r*r*r*pi)/3;}
public void display()
{super.display();
System.out.println("Volume of Sphere= "+v);}
}
class E7B
{
public static void main(String args[])
{
Volume v = new Volume();
v.gdata(); v.aclc(); v.vclc();
v.display();
}
}
OUTPUT
F:\java
program\OOPM>javac E7B.java
F:\java
program\OOPM>java E7B
Enter Radius
5
Area of Circle=
78.5
Volume of
Sphere= 523.3333333333334
I'm only getting volume Calc in the output.
ReplyDelete