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

(矩形的面积和周长)编写程序,使用以下公式计算并显示宽度为4.5、高度为7.9的矩形的面积和周长。

面积 = 宽 × 高
/*
 * 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_9;

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

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        
        double S = 0.0;
        double perimeter = (4.5 + 7.9) * 2;
        S = 4.5 * 7.9;
        System.out.println("面积:" + S);
        System.out.println("周长:" + perimeter);
        
    }
    
}

猜你喜欢

转载自blog.csdn.net/weixin_40476031/article/details/85768550