Create the design for determining if a point is inside, on, or outside of the rectangle. Drawing out the rectangle and labeling the coordinates of all points will help you to visualize the problem. Once the design has been completed, write a program that prompts the user for the x and y coordinates for the lower left hand corner of a rectangle as well as the height and the width of the rectangle. After that, you will need to get the coordinates for the point from the user as well. Once all inputs have been entered by the user, determine if the point is inside the rectangle, on the rectangle, or outside the rectangle. If the point is inside the rectangle, print "inside the rectangle". If the point is on the rectangle, print "on the rectangle". If the point is outside of the rectangle, print "outside the rectangle". Example output: Enter the x coordinate of the lower left hand corner of the rectangle: 1 Enter the y coordinate of the lower left hand corner of the rectangle: 1 Enter the height of the rectangle: 5 Enter the width of the rectangle: 3 Enter the x coordinate of the point: 2 Enter the y coordinate of the point: 1 on the rectangle There are 10 tests. They test for the point being in the rectangle, on the rectangle, and outside the rectangle. They also test with different points for the rectangle and different coordinates for the point. One test, test 7, tests for correct white space, but the other tests do not. Each test is worth 10 points.
Create the design for determining if a point is inside, on, or outside of the rectangle. Drawing out the rectangle and labeling the coordinates of all points will help you to visualize the problem.
Once the design has been completed, write a program that prompts the user for the x and y coordinates for the lower left hand corner of a rectangle as well as the height and the width of the rectangle. After that, you will need to get the coordinates for the point from the user as well. Once all inputs have been entered by the user, determine if the point is inside the rectangle, on the rectangle, or outside the rectangle. If the point is inside the rectangle, print "inside the rectangle". If the point is on the rectangle, print "on the rectangle". If the point is outside of the rectangle, print "outside the rectangle".
Example output:
Enter the x coordinate of the lower left hand corner of the rectangle: 1
Enter the y coordinate of the lower left hand corner of the rectangle: 1
Enter the height of the rectangle: 5
Enter the width of the rectangle: 3
Enter the x coordinate of the point: 2
Enter the y coordinate of the point: 1
on the rectangle
There are 10 tests. They test for the point being in the rectangle, on the rectangle, and outside the rectangle. They also test with different points for the rectangle and different coordinates for the point. One test, test 7, tests for correct white space, but the other tests do not. Each test is worth 10 points.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images