Kamrul13981

5

Mar 1st, 2021
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1.  
  2. package task5;
  3. class Rectangle {
  4.     int length, breadth;
  5.     public Rectangle(int length, int breadth){
  6.         this.length = length;
  7.         this.breadth = breadth;
  8.     }
  9.     public int Area(){
  10.         return length*breadth;
  11.     }
  12. }
  13.  
  14. public class Task5 {
  15.  
  16.    
  17.     public static void main(String[] args) {
  18.        
  19.        Rectangle rect1 = new Rectangle(4,5);
  20.         Rectangle rect2 = new Rectangle(5,8);
  21.         System.out.println("The Area of two rectangles 1:"+rect1.Area()+" \nThe Area of two rectangles 2:"+rect2.Area());
  22.     }
  23.    
  24. }
Advertisement
Add Comment
Please, Sign In to add comment