悍马加固材料:我的JAVA水平太垃圾~~~麻烦各位GG,JJ帮忙!JAVA编程题,

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/25 16:08:38
1 创建一个Rectangle(矩形)类。该类有两个属性:width(宽)、height(高);有两个方法:girth()(计算周长)、area()(计算面积)。

2 创建一个窗口,单击“提示”按钮可出现一个写有“你好!”文字的对话框 。

尽量使用最简单的JAVA语句
先谢谢各位哥哥 姐姐
做出任何一个都会加分

1.public class Rectangle
{
int width;
int height;
public int girth()
{
return (width+height)*2;
}
public int area()
{
return width*height;
}
}

public class Rectangle {
double width = 0;
double height = 0;
public double girth(){//周长
return (width + height) * 2;
}
public double area(){//面积
return width * height;
}

public static void main(String[] args) {//测试方法
Rectangle re = new Rectangle();
re.width = 10;
re.height = 10;
re.girth();
re.area();
}
}