您的位置:首页 > 编程语言 > Java开发

java语言程序设计(基础篇)第十版编程练习题[1.8]

2019-01-04 11:09 537 查看

(圆的面积和周长)编写程序,使用以下公式计算并显示半径为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));
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: