电脑编程里肿么求圆的周长与面积?

发布于2022-01-13 07:29:35
4个回答
admin
网友回答2022-01-13
#includestdio.h #define PHI 3.14 void main() { float zhou,s,r;//zhou是周长,s是面积,r是半径 printf(请输入半径:); scanf(%f,&r); zhou=2*PHI*r;//周长 s=PHI*r*r;//面积 printf(r=%.2f,zhou=%.2f,s=%.2f\n,r,zhou,s); }

希望采纳
admin
网友回答2022-01-13
4楼我服了你了 呵呵 他封的的确很好啊 更能体现OOP的精神
admin
网友回答2022-01-13
public class test
{
public static void main(String args[])
{
float r;
float ares;
System.out.println(please input the radius:);
r=System.in.read();
ares=3.14*r*r;
System.out.println(the ares is:+ares);
}
}
admin
网友回答2022-01-13
import java.io.*;
import java.util.*;

abstract class VolumeArea {

double pi = 3.14169;

abstract float volume(double r);

abstract float area(double r);
}

public class VolumeAndArea extends VolumeArea {

public static void main(String[] args) throws IOException {

Scanner cin = new Scanner(System.in);
System.out.print(Please input the radius : );
double r = cin.nextDouble();
VolumeAndArea x = new VolumeAndArea();

System.out.println(The volume is : + x.volume(r));
System.out.println(The area is : + x.area(r));
}

float volume(double r) {

return (float) (4 * pi * r * r * r / 3);
}

float area(double r) {

return (float) (pi * r * r);
}
}

回到
顶部