156k views
1 vote
Write code which takes inputs and creates two Rectangle objects (using the edhesive.shapes.Rectangle class) and compares them using the equals method.

JAVA!!

User TomoMiha
by
4.4k points

1 Answer

2 votes

Answer:

System.out.println("Enter length:");

Scanner scan = new Scanner(System.in);

Double x = scan.nextDouble();

System.out.println("Enter 2 lengths:");

Double a = scan.nextDouble();

Double b = scan.nextDouble();

Rectangle rect = new Rectangle(x);

Rectangle rect2 = new Rectangle (a,b);

if (rect2.equals(rect)){

System.out.print("Congruent Rectangles");

}

else {

System.out.print("Different Rectangles");

}

}

}

Step-by-step explanation:

User Jocko
by
4.3k points