java语言程序设计第十版编程练习题[1.8]

(圆的面积和周长)编写程序,使用以下公式计算并显示半径为5.5的圆的面积和周长。

周长 = 2 × 半径 × π
面积 = 半径 × 半径 × π
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package dome1_8;

/**
 *
 * @author Administrator
 */
public class Dome1_8 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        double radius = 5.5;//半径
        double pi = 3.14;
        System.out.println("周长:" + (2 * radius * pi));
        System.out.println("面积:" + (radius * radius * pi));
    }
    
}

猜你喜欢

转载自blog.csdn.net/weixin_40476031/article/details/85763095
今日推荐