rectangle

来源:互联网 发布:网络空间安全战略 编辑:程序博客网 时间:2024/06/05 04:12
/* * To change this template, choose Tools | Templates * and open the template in the editor. *//** * * @author Administrator */import java.util.Scanner;public class Example2_6 {    public static void main(String agrs[]){        Rect rectangle=new Rect();        Scanner reader =new Scanner (System.in);        System.out.println("input rectangle's width and affirm");        rectangle.width = reader.nextDouble();                System.out.println("input rectangle's heitght and affirm");        rectangle.height= reader.nextDouble();                double area=rectangle.getArea();        System.out.println("the area of rectangle is :"+area);            }    }/* * To change this template, choose Tools | Templates * and open the template in the editor. *//** * * @author Administrator */public class Rect {    double width;    double height;    double getArea()    {        double area=width*height;        return area;    }}

0 0
原创粉丝点击