CircumferenceTester.java
资源名称:Java.rar [点击查看]
上传用户:szfcled
上传日期:2022-06-12
资源大小:236k
文件大小:1k
源码类别:
文件格式
开发平台:
Java
- class Circle {
- static double PI = 3.14159265;
- int radius;
- public double circumference() {
- return 2 * PI * radius;
- }
- }
- public class CircumferenceTester {
- public static void main(String args[]) {
- Circle c1 = new Circle();
- c1.radius = 50;
- Circle c2 = new Circle();
- c2.radius = 10;
- double circum1 = c1.circumference();
- double circum2 = c2.circumference();
- System.out.println("Circle 1 has circumference " + circum1);
- System.out.println("Circle 2 has circumference " + circum2);
- }
- }