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 nonpositive 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, eg
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, eg
Using builtin 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 userentered x and y values is within
the rectangle centered at the userentered 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, is inside the rectangle centered at with width and height The point is outside the rectangle. The distance formula to determine absolute distance between points x y and x y is: xxyy 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
