Question: Write a Java program that prompts the user to enter: rectangle width and rectangle height If a rectangle with a non - positive dimension is

Write a Java program that prompts the user to enter:
rectangle width and rectangle height
If a rectangle with a non-positive dimension is entered, do not perform any calculations and
output an error message.
If given a valid rectangle, prompt the user to enter:
x and y coordinates for the center of the rectangle. This should be entered as a String
value with two numbers (any number of digits) separated by a comma only, e.g.2,2
x and y coordinates for the point to test. This should be entered as a String value with
two numbers (any number of digits) separated by a comma only, e.g.6,4
Using built-in String methods, break the two ordered pairs into four individual x and y values.
Note that these values will need to be numeric for future calculations.
The program should then check whether the point at the user-entered x and y values is within
the rectangle centered at the user-entered x and y values with the specified width and height.
Do not try to error check the String input; assume all input will be given in the correct format
with a comma and no spaces. You may also assume all numbers entered by the user are whole
numbers.
For example, (2,2) is inside the rectangle centered at (0,0) with width 10 and height 5. The point (6,4) is outside the rectangle. The distance formula to determine absolute distance between points (x 1, y1) and (x2, y2) is: ((x2-x1)^2+(y2-y1)^2) To determine only the horizontal or vertical distance, do not add the corresponding component before taking the square root. To determine only the horizontal or vertical distance, do not add the corresponding component
before taking the square root

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!