13589692269
发表于 2015-05-14
1321354687984651321
飞翔的小默
发表于 2015-05-14
11111111111
小花卷
发表于 2015-05-14
111111111111111111
辣戈甚么
发表于 2015-05-14
1111111111111111111111111111
377717833
发表于 2015-05-14
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;
}
}
}
}
luchesis
发表于 2015-05-14
本帖隐藏内容需回复可见
wyh85605021
发表于 2015-05-14
11111111111144444444444444444444444
南宫宇
发表于 2015-05-14
444444444444444444444444444444
devilraingy
发表于 2015-05-14
111111111111111111111111111111111111111
zxszxszxs
发表于 2015-05-14
感谢楼主分享!!!