Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java code Introduction For this assignment you are going to write a program that tests if points are inside or outside of circles and rectangles.

Java codeimage text in transcribedimage text in transcribedimage text in transcribed

Introduction For this assignment you are going to write a program that tests if points are inside or outside of circles and rectangles. The purpose of this assignment is to further familiarize you with concepts you already know from Py thon/ C++ and how they are done in Java; conditionals, loops, and methods. Assignment 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 , the first circle is , and , the first rectangle is , , , . . Each array index is the next point, circle, or rectangle. To create the report... - 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. The coordinate system is Cartesian; origin is [0,0]. In the diagram below, the right hand side of the rectangle is left + width, and the bottom of the rectangle is top - height. The following diagram illustrates the coordinates of rectangle. For a rectangle with a width of 8 and height of 6 , with it's left at and top at 8 , the diagram looks like. (left: 0, top: 8) (right: 8, bottom: 2) The above diagram isn't scaled correctly because vertical and horizontal characters take up a different amount of space. The numbers are the important features, try to see past that the characters skew the image

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

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions

Question

What steps should be taken to address any undesirable phenomena?

Answered: 1 week ago