java語言程式設計第十版程式設計練習題[1.8]
阿新 • • 發佈:2019-01-04
(圓的面積和周長)編寫程式,使用以下公式計算並顯示半徑為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));
}
}