Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*CODE IN JAVA* Write a program that produces the following example output... --- Report of Points and Circles --- Point(1.0, 1.0) is inside Circle(0.0, 0.0)

*CODE IN JAVA*

Write a program that produces the following example output...

--- Report of Points and Circles --- Point(1.0, 1.0) is inside Circle(0.0, 0.0) Radius: 3.0 Point(2.0, 2.0) is inside Circle(0.0, 0.0) Radius: 3.0 Point(3.0, 3.0) is outside Circle(0.0, 0.0) Radius: 3.0 Point(4.0, 4.0) is outside Circle(0.0, 0.0) Radius: 3.0 Point(1.0, 1.0) is outside Circle(5.0, 5.0) Radius: 3.0 Point(2.0, 2.0) is outside Circle(5.0, 5.0) Radius: 3.0 Point(3.0, 3.0) is inside Circle(5.0, 5.0) Radius: 3.0 Point(4.0, 4.0) is inside Circle(5.0, 5.0) Radius: 3.0 --- Report of Points and Rectangles --- Point(1.0, 1.0) is inside Rectangle(-2.5, 2.5, 3.5, -2.5) Point(2.0, 2.0) is inside Rectangle(-2.5, 2.5, 3.5, -2.5) Point(3.0, 3.0) is outside Rectangle(-2.5, 2.5, 3.5, -2.5) Point(4.0, 4.0) is outside Rectangle(-2.5, 2.5, 3.5, -2.5) Point(1.0, 1.0) is outside Rectangle(-2.5, 5.0, 2.5, 2.5) Point(2.0, 2.0) is outside Rectangle(-2.5, 5.0, 2.5, 2.5) Point(3.0, 3.0) is outside Rectangle(-2.5, 5.0, 2.5, 2.5) Point(4.0, 4.0) is outside Rectangle(-2.5, 5.0, 2.5, 2.5) 

Your program must meet the following specifications:

  • Write a method static void reportPoint(double x, double y) that prints the details for a single point. For example it would print, without a newline: Point(1.0, 1.0)
  • Write a method static void reportCircle(double x, double y, double r) that prints the details for a single circle. For example it would print, without a newline: Circle(0.0, 0.0) Radius: 3.0
  • Write a method static void reportRectangle(double left, double top, double width, double height) that prints the details for a single rectangle.
    • The report of the rectangle should show the left, top, right, and bottom values, rather than the left, top, width, and height.
  • Write a method static boolean isPointInsideCircle(double ptX, double ptY, double circleX, double circleY, double circleRadius) that tests if a point is inside a circle.
    • A point on the edge of a circle is considered inside the circle.
    • This method should not print anything to the console.
  • Write a method static boolean isPointInsideRectangle(double ptX, double ptY, double rLeft, double rTop, double rWidth, double rHeight) that tests if a point is inside a rectangle.
    • A point on the edge of a rectangle is considered inside the rectangle.
    • This method should not print anything to the console.
  • In the main method use the following statements to initialize the point, circle, and rectangle data.
 double[] ptX = { 1, 2, 3, 4 }; double[] ptY = { 1, 2, 3, 4 }; double[] circleX = { 0, 5 }; double[] circleY = { 0, 5 }; double[] circleRadius = { 3, 3 }; double[] rectLeft = { -2.5, -2.5 }; double[] rectTop = { 2.5, 5.0 }; double[] rectWidth = { 6.0, 5.0 }; double[] rectHeight = { 5.0, 2.5 }; 

Looking at these declarations, the first point is ptX[0] and ptY[0], the first circle is circleX[0], circleY[0], and circleRadius[0], the first rectangle is rectLeft[0], rectTop[0], rectWidth[0], and rectHeight[0]. Each array index is the next point, circle, or rectangle.

  • In the main method, loop over the circles, then the points, reporting on each as appropriate.
  • In the main method, loop over the rectangles, then the points, reporting on each as appropriate.
  • Use the various 'report' methods to produce the output.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 11G SQL

Authors: Joan Casteel

2nd Edition

1133947360, 978-1133947363

More Books

Students also viewed these Databases questions

Question

Define Administration?

Answered: 1 week ago

Question

Define Decision making

Answered: 1 week ago