王梦然

2013年3月19日

例题4-4(两个Lader对象共享bottom)

摘要: class Lader{double above,height;static double bottom;void setAbove(double a){above=a;}void setBottom(double b){bottom=b;}double getAbove(){return above;}double getBottom(){return bottom;}}class Example4_4{public static void main(String args[]){Lader.bottom=60;Lader laderOne,laderTwo;System.out.print 阅读全文

posted @ 2013-03-19 22:17 快乐的铲屎官 阅读(178) 评论(0) 推荐(0) 编辑

例题4-3

摘要: class Lader{double above,bottom,height;Lader(){}Lader(double a,double b,double h){above=a;bottom=b;height=h;}public void setAbove(double a){above=a;above=a;}public void setBottom(double b){bottom=b;}public void setHeight(double h){height=h;}double computeArea(){return(above+bottom)*height/2.0;}}publ 阅读全文

posted @ 2013-03-19 21:48 快乐的铲屎官 阅读(133) 评论(0) 推荐(0) 编辑

例题4-2

摘要: class Circle{double radius;double getArea(){double area=3.14*radius*radius;return area;}}public class Example4_2{public static void main (String args[]){Circle circle;circle=new Circle();circle.radius=163.16;double area=circle.getArea();System.out.printf("半径是%5.3f的圆的面积:\n%5.3f\n",circle.ra 阅读全文

posted @ 2013-03-19 21:16 快乐的铲屎官 阅读(115) 评论(0) 推荐(0) 编辑

输出圆的面积的Java程序

摘要: public class ComputerCircleArea{public static void main(String args[]){double radius;double area;radius=163.16;area=3.14*radius*radius;System.out.printf("半径是%5.3f的圆的面积:\n%5.3f\n",radius,area);}} 阅读全文

posted @ 2013-03-19 16:54 快乐的铲屎官 阅读(729) 评论(0) 推荐(0) 编辑

导航