首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

求园柱体的表面积跟体积

2012-10-30 
求园柱体的表面积和体积第一题:public class Trianglele { Point p1 new Point() Point p2 new Point

求园柱体的表面积和体积

第一题:public class Trianglele { Point p1 = new Point(); Point p2 = new Point(); Point p3 = new Point(); void setTri(double x1, double y1, double x2, double y2, double x3, double y3) {  this.p1.x = x1;  this.p1.y = y1;  this.p2.x = x1;  this.p1.y = y2;  this.p3.x = x3;  this.p3.y = y3; } double Circumference(Trianglele t) {  double line1, line2, line3;  line1 = Math.hypot((t.p1.x - t.p2.x), (t.p1.y - t.p2.y));  line2 = Math.hypot((t.p2.x - t.p3.x), (t.p2.y - t.p3.y));  line3 = Math.hypot((t.p1.x - t.p3.x), (t.p1.y - t.p3.y));  return line1 + line2 + line3; }  double Area(Trianglele t) {  double line1, line2, line3;  line1 = Math.hypot((t.p1.x - t.p2.x), (t.p1.y - t.p2.y));  line2 = Math.hypot((t.p2.x - t.p3.x), (t.p2.y - t.p3.y));  line3 = Math.hypot((t.p1.x - t.p3.x), (t.p1.y - t.p3.y));  double p = Circumference(t)/2;  return Math.sqrt((p-line1)*(p-line2)*(p-line3)*p); } public static void main(String[] args) {  Trianglele t =new Trianglele();  t.setTri(0, 0, 0, 3, 4, 0);  System.out.println("三角形周长:"+t.Circumference(t));  System.out.println("三角形面积:"+t.Area(t)); }}class Point { double x, y;} 第二题:public class Trianglele { Point p1 = new Point(); Point p2 = new Point(); Point p3 = new Point(); Trianglele(double x1, double y1, double x2, double y2, double x3, double y3) {  this.p1.x = x1;  this.p1.y = y1;  this.p2.x = x1;  this.p1.y = y2;  this.p3.x = x3;  this.p3.y = y3; } double Circumference(Trianglele t) {  double line1, line2, line3;  line1 = Math.hypot((t.p1.x - t.p2.x), (t.p1.y - t.p2.y));  line2 = Math.hypot((t.p2.x - t.p3.x), (t.p2.y - t.p3.y));  line3 = Math.hypot((t.p1.x - t.p3.x), (t.p1.y - t.p3.y));  return line1 + line2 + line3; }  double Area(Trianglele t) {  double line1, line2, line3;  line1 = Math.hypot((t.p1.x - t.p2.x), (t.p1.y - t.p2.y));  line2 = Math.hypot((t.p2.x - t.p3.x), (t.p2.y - t.p3.y));  line3 = Math.hypot((t.p1.x - t.p3.x), (t.p1.y - t.p3.y));  double p = Circumference(t)/2;  return Math.sqrt((p-line1)*(p-line2)*(p-line3)*p); } public static void main(String[] args) {  Trianglele t =new Trianglele(0, 0, 0, 3, 4, 0);  System.out.println("三角形周长:"+t.Circumference(t));  System.out.println("三角形面积:"+t.Area(t)); }}class Point { double x, y;} 第三题:public class Cylinder { double radius,height; public static void main(String[] args) {  Cylinder c = new Cylinder();  System.out.println("圆柱体体积:"+c.Volume(10, 5)); } double Volume(double r,double h) {  return 3.14*r*r*h; } } 

?

热点排行