Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this program, you will be making two distinct comparisons between a rectangle and a square. Three values will be provided to be read. The
In this program, you will be making two distinct comparisons between a rectangle and a square.
Three values will be provided to be read. The format of the input will be three floating point numbers provided in one line:
These three floating point numbers tell you: The width of a rectangle, The length of a rectangle, The side length of a square,
These values will be no larger than
You need to add error checking for these three values. Each of these values must be at least in size. Meaning if a size for any of these three variables is less than then you will exit immediately. If this case occurs, you will only print Invalid Side Values and immediately exit.
You will make two separate comparisons between the rectangle and the square:
Determine if the square fits inside of the rectangle
Determine which shape has a larger area
For determining if the square fits inside of the rectangle, you will need to see if the length of each of the square's sides is exclusively smaller than the length and width of the rectangle.
In other words, are and larger than If they are, then the square can fit inside the rectangle. If the square fits inside of the rectangle, you will print Yes and if it does not you will print No What you print here will have a newline follow it
For determining which shape has a larger area, you will need to calculate area of each of the shapes. The formula for generally calculating the area of a rectangle is length width which will be used here for both shapes. For the rectangle, you will multiply and for the square you will multiply
You will print the name of which shape has the larger surface area. If the rectangle is larger, you will print Rectangle. If the square is larger you will print Square. If they have the same surface area, print Equal. This will also terminate with a new line.
Sample Test Cases
tableInputOutputYesRectangle
Yes
Rectangle
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started