Question: Repeat Exercise Testing P2.11, but now write a graphical application that shows the line and the points. Draw each point as a tiny circle.

Repeat Exercise ••• Testing P2.11, but now write a graphical application that shows the line and the points. Draw each point as a tiny circle. Use the drawString method to draw each distance next to the point, using calls:

g2.drawstring("Distance: #1 + distance, p.getX(), p.getY());

Data from testing P2.11

Write a program LineDistanceTester that constructs a line joining the points (100, 100) and (200, 200), then constructs points (100, 200), (150, 150), and (250, 50). Print the distance from the line to each of the three points, using the ptSegDist method of the Line2D class. Also print the expected values. (Draw a sketch on graph paper to find what values you expect.)

g2.drawstring("Distance: #1 + distance, p.getX(), p.getY());

Step by Step Solution

3.48 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

It seems like you are asking for help in writing a graphical Java application that uses the javaawt and javaxswing libraries to draw a line between tw... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java Programming Questions!