1 java编写一个应用程序,创建一个圆类,在类中定义半径成员变量、求面积和求周长的方法, 在主类中定义圆类对象,根据输入的圆的半径求它的面积和周长. 2java编写一个应用程序,创建一个圆类,在类中定义半径成员变量、求面积和求周长的方法,在主类中定义圆类对象,根据输入的圆的半径求它的面积和周长....
package lianxi;publicclassYuan {publicstaticvoidmain(String[] args) {doubler=3.0;doublecircle=2*r*Math.PI;doublearea=Math.PI*r*r; System.out.println("圆的周长为:"+circle); System.out.println("圆的面积为:"+area); } }
System.out.println("圆的周长为:"+circle); System.out.println("圆的面积为:"+area); } }
temp=Double.parseDouble(str);System.out.print("改圆的直径为-->"+round.diameter(temp)+"\n"+ "改圆的周长为-->"+ round.perimeter(temp)+"\n"+ "改圆的面积为-->"+ round.area(temp));} } 楼主别忘了给分啊~~~
实现思路:输入一个半径的值,之后即可求出周长和面积:代码举例:import javax.swing.JOptionPane;class account { public static void main(String[] args){ String radiusString = JOptionPane.showInputDialog(null ,"请输入半径 : " , "计算" , JOptionPane.QUESTION_MESSAGE);double radius = ...
public class Circle { int radius; //定义变量半径 double perimeter() //周长方法 { return radius*2*3.14;} double area() //面积方法 { return radius*radius*3.14;} public static void main(String[] agrs){ try { BufferedReader buf = new BufferedReader(new InputStreamReader(...
public static void main(String[] args) { System.out.println("请输入圆半径:");Scanner input = new Scanner(System.in);float r = input.nextFloat();float perimeter = getPerimeter(r);float area = getArea(r);System.out.println("圆的周长为:" + perimeter);System.out.println("圆...
new DecimalFormat("#.00");String zcString = df.format(zc);String sString = df.format(s);l.setText("面积:" + sString);l.setText(l.getText() + "周长:" + zcString);} });} / param args / public static void main(String[] args) { Test t = new Test();} } ...
public class Test { public static void main(String[] args) { double l = 3.0;double perimeter = 2 * Math.PI * l;double area = l * l * Math.PI;System.out.println("周长" + perimeter);System.out.println("面积" + area);} } ...
System.out.println("圆的周长为-->"+this.perimeter(radius)+"\n"+ "圆的面积为-->"+this.area(radius));} } public class OperateDemo{ public static void main(String args[]){ Round round=new Round();System.out.print("请输入圆的半径-->");Scanner scan=new Scanner(System.in)...