发布网友 发布时间:2023-11-08 23:24
共0个回答
publicvoidprint(doubleradius){System.out.println("圆的周长为-->"+this.perimeter(radius)+"\n"+"圆的面积为-->"+this.area(radius));}}publicclassOperateDemo{publicstaticvoidmain(Stringargs[]){Roundround=newRound();System.out.print("请输入圆的半径-->");Scannerscan=newScanner...
用java编写一个圆类Circle,该类拥有:一个成员变量 radius(私有,浮点型...参考一下这个吧:创建一个圆类Circle,该类可以接收圆半径,并具有计算圆周长和面积的方法。import java.math.*;import javax.swing.*;class Circle{ int r;Circle(int r){ this.r=r;} public void getS(){ System.out.println("面积是:"+Math.PI*r*r);} public void getL(){ System.out...
JAVA:定义一个圆类Circle,成员变量:半径 radius;public class Main{ public static void main(String[] ags) { double radius = 2.5; double width = radius * 2; double height = 10; Circle circle = new Circle(radius); System.out.println("圆形周长:" + circle.calculgirth()); System.out.println("圆形面积...
Java设计一个圆类Circle,并测试,要求: Circle类中有两个成员方法,一个...public static void main(String[] args) { double radius = 10;Circle circle = new Circle();circle.setRadius(radius);System.out.println("半径" + radius + "的圆,周长: " + circle.perimeter() + ", 面积: " + circle.area());double radius2 = 11;Circle circle2 = new Circle(...
急求Java代码,定义一个Circle(圆类型)public static void main(String[] args){ Circle c=new Circle(3,4,5);System.out.printf("圆心:(%f,%f),半径:%f,面积:%f",c.x,c.y,c.r,c.countArea());} } class Circle { public Circle(){ this(0,0,0);} public Circle(double x,double y,double r){ this.x=x;thi...
JAVA定义圆形类。} public double getArea(){ return Math.PI*r*r;} public double getPerimeter(){ return 2*Math.PI*r;} } public class TestCircle{ public static void main(String [] args){ //两个不同对象 Circle circle1 = new Circle();Circle circle2 = new Circle();//设置不同半径 circle1....
JAVA高手请帮帮忙,写出程序!谢谢!考试就靠它了!void main(String[]args){ int cr = 2;Circle c = new Circle(cr);int r = c.getR();System.out.println("圆的半径为:"+r);System.out.println("圆的面积为:"+c.area(r));System.out.println("圆的周长为:"+c.circleLength(r));} } 【编译与运行】编译:javac Circle.java ...
C++编程序题:(一)定义一个圆类XY,计算圆的面积和周长(). 要求:1.该...//类定义结束 int main() //主函数{double t; //双精度变量 XY O; //XY类对象 printf("请输入半径:"); //提示输入半径 scanf("%lf",&t); //从键盘接受半径大小 O.Set(t); //以t的值设置对象O的半径 t=O.Grith(); ...
用JAVA编写程序,编写一个Rect类 ,要求,(1)Rect类的私有成员变量有:a...public Double area(){ return this.a* this.b;} public void display(){ System.out.println(this.area());} } public class userect { public static void main(String[] args){ Rect rect1 = new Rect();rect1.display();Rect rect2 = new Rect(10,10);rect2.display();} } ...
用java写程序,定义一个student类,包含成员变量有学号、姓名、性别、班...public class Student {\x0d\x0a\x0d\x0a/**\x0d\x0a * @param args\x0d\x0a */\x0d\x0aboolean master; //定义成员变量\x0d\x0aint num;\x0d\x0aString name,sex;\x0d\x0adouble math,chinese,english,score=0.0,average=0.0;\x0d\x0a\x0d\x0aStudent(int...