Create a rectangle class that can compute the area and the sum of its sides. Create a specialized method that will allow the class to compare other rectangle objects. The comparison should identify the larger rectangle according to the object’s area. You should be able to implement the class where the user provides rectangle dimensions. The program should be able to display which of the rectangle inputs is larger using the Rectangle class method that you defined. Sample output: Enter Length R1: 1 Enter Width R1: 1 Enter Length R2: 2 Enter Width R2: 2 Results: R1 Area: 1 R1 Sum: 2 R2 Area: 4 R2 Sum: 4 R2 is the bigger Rectangle! Note: All characters in boldface are user inputs.
Create a rectangle class that can compute the area and the sum of its sides. Create a specialized method that will allow the class to compare other rectangle objects. The comparison should identify the larger rectangle according to the object’s area. You should be able to implement the class where the user provides rectangle dimensions. The program should be able to display which of the rectangle inputs is larger using the Rectangle class method that you defined.
Sample output:
Enter Length R1: 1
Enter Width R1: 1
Enter Length R2: 2
Enter Width R2: 2
Results:
R1 Area: 1
R1 Sum: 2
R2 Area: 4
R2 Sum: 4
R2 is the bigger Rectangle!
Note: All characters in boldface are user inputs.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images