nnpc.net
当前位置:首页 >> jAvA求圆面积及周长 >>

jAvA求圆面积及周长

public class Test { public static void main(String[] g) { Circle circle = new Circle(1); System.out.println("半径 "+circle.getR()); System.out.println("面积 "+circle.area()); System.out.println("周长 "+circle.circleLength()); } } class

public class circle{ final float PI=3.14f; int x,y; float get area();//get后不应有空格,括号不该有分号 { float area; area=PI*r*r;//变量r没有声明 Return area;//return不应该大写 } float get Permineter();//get后不应有空格,括号不该有分号 {float Z; Z=2*PI*r//缺分号 Return Z;//return不应该大写 }}

方法给你吧,具体的类你自己写吧 int r = 2; //半径 double zhouchang = Math.PI*r*2; //周长 System.out.println(zhouchang); 很简单的,你可以试一下.

public class test { public static void main(string[] args) { double[] d = new double[5]; // 半径 double[] area = new double[5]; // 面积 double[] zc = new double[5]; // 周长 double za = 0, zzc = 0; for(int i = 0; i // 产生5~20的随机数 d[i] = math.random() *

//为了方面,我不用输入部分了class App{ private double r; private double s; private double c; static final double PI=3.14159265; App(double d){ r=d; } public void showinputdialog(double d){ r=d; } public void showmessagedialog(){ s=PI*r*r; c=PI*2*r;

面积=半径的平方Xπ 直径=周长/π=面积/π/半径X2 半径=面积/π/半径=周长/π/2 周长=半径X2Xπ=直径Xπ

import javax.swing.*; import java.awt.*; import java.awt.event.*; public class a { public static void main(String []args) { b a=new b(); } } class b extends JFrame { private JLabel x,y,z,a; private JTextField x1,y1,z1,a1; private JButton bo,bo2; public b() {

实现思路:输入一个半径的值,之后即可求出周长和面积:代码举例:import javax.swing.JOptionPane;class account{public static void main(String[] args) {String radiusString = JOptionPane.showInputDialog(null ,"请输入半径 : " , "计算

importjava.io.bufferedreader;importjava.io.inputstreamreader;publicclasstest{publicstaticvoidmain(string[]args){doubler=0,s,c,v;try{system.out.print("请输入圆的半径:");r=double.parsedouble((newbufferedreader(newinputstreamreader(

网站首页 | 网站地图
All rights reserved Powered by www.nnpc.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com