You are on page 1of 3

// NAME: ANKITA SHITKAL

// SYBTECH B B2 2229
// COMPARE TWO RECTANGLE
import java.util.*;
class Rectangle
{
private int l,b,area;
private String c;
Rectangle()
{
Scanner s=new Scanner(System.in);
System.out.println("enter Length");
l=s.nextInt();
System.out.println("enter width");
b=s.nextInt();
System.out.println("enter Colour");
c=s.next();

if(l<0 || b<0)
{
System.out.println("Invalid length And width");
System.exit(0);
}
}
public int width()
{
return b;
}
public int length()
{
return l;
}

public String colour()


{
return c;
}
public int area()
{
area=l*b;
return area;
}
}
class Compare
{
public static void main(String args[])
{
System.out.println("Enter details of rectangles:");
System.out.println("1st Rectangle:");
Rectangle r1=new Rectangle();
System.out.println("2st Rectangle:");
Rectangle r2=new Rectangle();

if((r1.area()==r2.area()) && (r1.colour().equalsIgnoreCase(r2.colour())))


{
System.out.println("Reactangles are macthing");
}
else
{

System.out.println("Reactangles are not macthing");


}
}
}

/*
OUTPUT:

ccoew@ccoew-All-Series:~/Desktop/Div-B/B2/2229$ javac Compare.java


ccoew@ccoew-All-Series:~/Desktop/Div-B/B2/2229$ clear

ccoew@ccoew-All-Series:~/Desktop/Div-B/B2/2229$ javac Compare.java


ccoew@ccoew-All-Series:~/Desktop/Div-B/B2/2229$ java Compare
Enter details of rectangles:
1st Rectangle:
enter Length
23
enter width
12
enter Colour
red
2st Rectangle:
enter Length
45
enter width
54
enter Colour
blue
Reactangles are not macthing
ccoew@ccoew-All-Series:~/Desktop/Div-B/B2/2229$ java Compare
Enter details of rectangles:
1st Rectangle:
enter Length
12
enter width
13
enter Colour
Purple
2st Rectangle:
enter Length
12
enter width
13
enter Colour
purple
Reactangles are macthing
ccoew@ccoew-All-Series:~/Desktop/Div-B/B2/2229$
*/

You might also like