java如何计算矩形的面积和周长?

2022-04-13教育164

class Ractangle {

double width;

double height;

public Ractangle(double w,double h){

width=w;

height=h;

void Area{

System.out.println( width*height);

void perimeter{

System.out.println(2*(width+height));

public class RectangleDemo {

public static void main(String args[]){

Ractangle ractangle=new Ractangle(40,50);

ractangle.Area;

ractangle.perimeter;