import java.util.Scanner;
interface JSolidFigure {
//表面积
void SurfaceArea();
//体积
void Volume();
}
//圆柱
class Cylinder implements JSolidFigure{
@Override
public void SurfaceArea() {
Scanner sc=new Scanner(System.in);
System.out.println("请输入半径:");
double r=sc.nextDouble();
System.out.println("请输入高:");
double h=sc.nextDouble();
double surfaceArea=2*Math.PI*r*r+2*Math.PI*r*h;
System.out.println("表面积:"+surfaceArea);
}
@Override
public void Volume() {
Scanner sc=new Scanner(System.in);
System.out.println("请输入半径:");
double r=sc.nextDouble();
System.out.println("请输入高:");
double h=sc.nextDouble();
double volume=Math.PI*r*r*h;
System.out.println("体积:"+volume);
}
}
//圆锥
class Cone implements JSolidFigure{
@Override
public void SurfaceArea() {
}
@Override
public void Volume() {
}
}
//球
class Ball implements JSolidFigure{
@Override
public void SurfaceArea() {
}
@Override
public void Volume() {
}
}
//长方
class Rectangular implements JSolidFigure{
@Override
public void SurfaceArea() {
}
@Override
public void Volume() {
}
}
//测试
public class SolidFigure{
public static void main(String[] args) {
//多态
JSolidFigure jsf=new Cylinder();
System.out.println("下面求圆柱表面积+++++++++++++++++++++++++++++++");
jsf.SurfaceArea();
System.out.println("下面求圆柱体积+++++++++++++++++++++++++++++++++");
jsf.Volume();
}
}