Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

****Please anyone I need help with this**** Use the following statement in BlueJ

ID: 3829261 • Letter: #

Question

                                     ****Please anyone I need help with this****

Use the following statement in BlueJ's CodePad to create the LineSegment AB as seen in the diagram:
LineSegment AB = new LineSegment( new CSC142Point( 1,6 ), new CSC142Point( 5, 1) );

Create another LineSegment that represents CD in the diagram.

B) What statement(s) would you write to successfully create a new LineSegment whose endpoints are the first point of AB and the first point of CD.

G) Show the statement(s) that you used to find the distance from the first point of CD to the origin.

     **** I posted this answer I recieved the Comment below ****

B.) To create new LineSegment
LineSegment AB = new LineSegment();
AB.setLineSegment(1.0,6.0,5.0,1.0);
LineSegment CD= new LineSegment();
CD.setLineSegment(7.0,6.0,-7.0,-8.0);

G.) find the distance from point CD to origin.
we know that the distance d between the two points(X1,Y1) and (X2,Y2)
let us write:

The distance between two points (a,b) and (c,d) can be calculated using the below formula,
d= sqrt{(X2-X1)^2 +(Y2-Y1)^2};
so from this:
d= sqrt{(0-(-7)^2 + (0-(-8))^2};
d= sqrt{(7^2) + (8^2)};
d= sqrt{49+64};
d= sqrt{113}.

                                                           ***COMMENT***

Good start on this . However, you are limited to calling only LineSegment methods that exist in the class. For example, there is no LineSegment constructor that has no parameters, so that first line won't compile. Next, there is no method setLineSegment.

One approach to answering these questions is to have the LineSegment and CSC142Point classes open in BlueJ, using the documentation view instead of looking at the source code. This way, you're seeing an page similar to the Java API pages. This will make clearer what method signatures are available.

The question regarding distance is something you can answer by calling a method.

Try again?

D(-7, -3) A(1,6) B(5, 1)

Explanation / Answer

B)

Hence using that formula X1 and Y1 will be 0 and 0