Question: Programming Exercise 3.32 shows how to test whether a point is on an unbounded line. Revise Programming Exercise 3.32 to test whether a point is

Programming Exercise 3.32 shows how to test whether a point is on an unbounded line. Revise Programming Exercise 3.32 to test whether a point is on a line segment. Write a program that prompts the user to enter the three points for p0, p1, and p2 and displays whether p2 is on the line segment from p0 to p1. Here are some sample runs:

JEnter (1.5, 1.5) is on the line segment from (1.0, 1.0) to

Data from 3.32

Given a directed line from point p0(x0, y0) to p1(x1, y1), you can use the following condition to decide whether a point p2(x2, y2) is on the left of the line, on the right, or on the same line (see Figure 3.11):

(2.5, 2.5) Enter Enter three points for p0, pl, and p2: 1

Write a program that prompts the user to enter the three points for p0, p1, and p2 and displays whether p2 is on the left of the line from p0 to p1, on the right, or on the same line. Here are some sample runs:

1 2 2 3.5 3.5 PEnter (3.5, 3.5) is not on the

JEnter (1.5, 1.5) is on the line segment from (1.0, 1.0) to (2.5, 2.5) Enter Enter three points for p0, pl, and p2: 1 1 2 2 3.5 3.5 PEnter (3.5, 3.5) is not on the line segment from (1.0, 1.0) to (2.0, 2.0) >0 p2 is on the left side of the line (x1 x0)*(y2 y0) (x2 x0)*(yl y0) { =0 p2 is on the same line

Step by Step Solution

3.41 Rating (164 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Program plan Define the class PointLineSegment Define the mainmethod Prompt the user to enter the th... 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!