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

Use the following statement in BlueJ\'s CodePad to create the LineSegment AB as

ID: 3824002 • Letter: U

Question

Use the following statement in BlueJ's CodePad to create the LineSegment AB as seen in the diagram:

LineSegment AB = new LineSegment( new Point( 1,6 ), new Point( 5, 1) );

Create another LineSegment that represents CD in the diagram.

A) 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.

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

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

Explanation / Answer

A)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);

B)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:

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}.