import java.util.*;
import java.text.DecimalFormat; //隶属实验41
interface Shapeq
{
float pi=3.14F;
public double area();
public double volume();
}
class Cyl implements Shapeq
{
private double radius;
private int heigh;
public Cyl(double r,int h)
{
radius=r;heigh=h;
}
public double area()
{
return pi*radius*radius;
}
public double volume()
{
return area()*heigh;
}
}
interface Ach
{
public float ave();
}
class Per
{
String name;
int age;
public Per(String newN,int newA)
{
name=newN;age=newA;
}
public void intr()
{
System.out.println("你好,我是"+name+"今年"+age+" 岁");
}
}
class Student extends Per implements Ach
{
int Chinese;int Math;int English;
public Student(String newN,int newA)
{
super(newN,newA);
}
public void setS(int c,int m,int e)
{
Chinese=c;Math=m;English=e;
}
public float ave()
{
return (Chinese+Math+English)/3;
}
}
abstract class Shape
{
abstract public float Area();
abstract public void printArea();
}
class Rec extends Shape
{
int width,length;
public Rec(int newW,int newL)
{
width=newW;
length=newL;
}
public float Area()
{
return width*length;
}
public void printArea()
{
System.out.println("面积= "+Area());
}
}
class Cir extends Shape
{
final float pi=3.14F;
int rad;
public Cir(int newRad)
{
rad=newRad;
}
public float Area()
{
return pi*rad*rad;
}
public void printArea()
{
System.out.println("圆形面积= "+Area());
}
}
public class sy {
public static void main(String[] args)
{
int a=0;
Scanner reader=new Scanner(System.in);
System.out.println("=====输入要查询的实验项目35-42退出输入99======= ");
for(;;)
{
a=reader.nextInt();
if(a==99){System.out.println("已退出,谢谢使用!"); break;}
switch(a)
{
case 35:System.out.println("实验35 >>>>");
{
Cyl b=new Cyl(2,3);
DecimalFormat myF=new DecimalFormat("0.00");
System.out.println("圆柱体的面积是"+myF.format(b.area()));
System.out.println("圆柱体的体积是"+myF.format(b.volume()));
}
System.out.println("=====实验结束, 输入要查询的实验项目35-42 退出输入99======= ");
break;
case 41:System.out.println("实验41>>>> ");
{
Student s1=new Student("张三",16);
s1.intr();
s1.setS(80,90,80);
System.out.println("平均分="+s1.ave());
}
System.out.println("=====实验结束, 输入要查询的实验项目35-42退出输入99======= ");
;break;
case 42:System.out.println("实验42>>>> ");
{
Rec s1=new Rec(3,4);
Cir s2=new Cir(2);
s1.printArea();
s2.printArea();
}
System.out.println("=====实验结束, 输入要查询的实验项目35-42退出输入99======= ");
;break;
default: System.out.println("输入数字错误请重新输入,输入要查询的实验项目35-42, 退出输入99 "); break;
}
}
}
}