You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scanner input=new Scanner(System.in);
System.out.print("Enter the radius of the Sphere :");
r=input.nextDouble();
}
public void dispvolume()
{
vol=(4/33.14rrr);
System.out.println("Volume of Sphere : "+vol);
}
}
class Cylinder implements Volume
{
double R,h,vol;
public void readdata()
{
Scanner input=new Scanner(System.in);
System.out.print("Enter the radius of the Cylinder :");
R=input.nextDouble();
System.out.print("Enter the height of the Cylinder :");
h=input.nextDouble();
}
public void dispvolume()
{
vol=piRR*h;
System.out.println("Volume of the Cylinder: "+vol);
}
}
public class VolumeMain
{
public static void main(String args[])
{
Sphere obj=new Sphere();
obj.readdata();
obj.dispvolume();
Cylinder obj1=new Cylinder();
obj1.readdata();
obj1.dispvolume();
}
}
The text was updated successfully, but these errors were encountered:
import java.util.Scanner;
interface Volume
{
double pi=3.14;
void readdata();
void dispvolume();
}
class Sphere implements Volume
{
double r=0,vol;
public void readdata()
{
}
public void dispvolume()
{
vol=(4/33.14rrr);
System.out.println("Volume of Sphere : "+vol);
}
}
class Cylinder implements Volume
{
double R,h,vol;
public void readdata()
{
Scanner input=new Scanner(System.in);
System.out.print("Enter the radius of the Cylinder :");
R=input.nextDouble();
System.out.print("Enter the height of the Cylinder :");
h=input.nextDouble();
}
public void dispvolume()
{
vol=piRR*h;
System.out.println("Volume of the Cylinder: "+vol);
}
}
public class VolumeMain
{
public static void main(String args[])
{
Sphere obj=new Sphere();
obj.readdata();
obj.dispvolume();
Cylinder obj1=new Cylinder();
obj1.readdata();
obj1.dispvolume();
}
}
The text was updated successfully, but these errors were encountered: