Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
715 B
0
Indexable
Never
	 class Rectangle {
	 public int len;
	public int wid;

	Rectangle(){}
	Rectangle (int l,int w) {

		 len=l;
		 wid =w;
		
	}
	void input(int l,int w)
	{
		  len=l;
		 wid =w;
	}
	int area()
	{
		return len* wid;
	}
	void display()
	{
			System.out.print("len is : "+ len+"wid is : "+wid);
	}
	}
public class Main 
{
		    public static void main(String[] args) {
		        Rectangle r1 = new Rectangle(4, 6);
		       // r1.display();
		       r1.display();
		        System.out.print(" the area is: " + r1.area());
		        
		        Rectangle r2 = new Rectangle(6, 10);
		        r2.display();
		        System.out.print(" the area is: " + r2.area());
		    }
	 }



Leave a Comment