Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package task5;
- class Rectangle {
- int length, breadth;
- public Rectangle(int length, int breadth){
- this.length = length;
- this.breadth = breadth;
- }
- public int Area(){
- return length*breadth;
- }
- }
- public class Task5 {
- public static void main(String[] args) {
- Rectangle rect1 = new Rectangle(4,5);
- Rectangle rect2 = new Rectangle(5,8);
- System.out.println("The Area of two rectangles 1:"+rect1.Area()+" \nThe Area of two rectangles 2:"+rect2.Area());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment