Question: Programming Exercise 6.39 gives a method for testing whether three points are on the same line.Write the following method to test whether all the points
Programming Exercise 6.39 gives a method for testing whether three points are on the same line.Write the following method to test whether all the points in the array points are on the same line.public static boolean?sameLine(double[][] points)Write a program that prompts the user to enter five points and displays whether they are on the same line. Here are sample runs:
Exercise shows how to test whether a point is on the left side of a directed line, on the right, or on the same line. Write the methods with the following headers:
/** Return true if point (x2, y2) is on the left side of the
? ?* directed line from (x0, y0) to (x1, y1) */
public static boolean leftOfTheLine(double x0, double y0)
? ?double x1, double y1, double x2, double y2)
/** Return true if point (x2, y2) is on the same
? ?* line from (x0, y0) to (x1, y1) */
public static boolean onTheSameLine(double x0, double y0)
? ?double x1, double y1, double x2, double y2)
/** Return true if point (x2, y2) is on the
? ?* line segment from (x0, y0) to (x1, y1) */
public static boolean onTheLineSegment(double x0, double y0)
? double x1, double y1, double x2, double y2)
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, right, the same line, or on the line segment. Here are some sample runs:


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


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:

Enter five points: 3.4 2 6.5 9.5 2.3 2.3 5.5 5 -5 4 The five points are not on the same line -Enter Enter five points: 1 1 2 2 3 3 4 4 5 5 -Enter The five points are on the same line Enter three points for p0, pl, and p2: 11 2 2 1.5 1.5 JEnter (1.5, 1.5) is on the line segment from (1.0, 1.0) to (2.0, 2.0) Enter three points for p0, p1, and p2: 1 1 2 2 3 3 -Enter (3.0, 3.0) is on the same line from (1.0, 1.0) to (2.0, 2.0) Enter three points for p0, pl, and p2: 1 1 2 2 1 1.5 PEnter (1.0, 1.5) is on the left side of the line from (1.0, 1.0) to (2.0, 2.0)
Step by Step Solution
3.45 Rating (171 Votes )
There are 3 Steps involved in it
Program This program demonstrates whether the five points lie on the same line or not SameLine class import javautilScanner public class SameLine star... View full answer
Get step-by-step solutions from verified subject matter experts
