Programming Exercise 3.32 shows how to test whether a point is on the left side of a
Question:
Programming Exercise 3.32 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:
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:
Transcribed Image Text:
/** Return true if point (x2, y2) is on the left side of the directed line from (x0, y0) to (x1, y1) */ public static boolean left0fTheLine(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) Enter three points for p0, p1, and p2: 1 1 2 2 1.5 1.5 (1.5, 1.5) is on the line segment from (1.0, 1.0) to (2.0, 2.0) - Enter 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, p1, and p2: 1 1 2 2 1 1.5 (1.0, 1.5) is on the left side of the line from (1.0, 1.0) to (2.0, 2.0) Enter Enter three points for p0, p1, and p2: 1 1 2 2 1 -1 (1.0, -1.0) is on the right side of the line from (1.0, 1.0) to (2.0, 2.0) -Enter
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 50% (12 reviews)
Sample Output 1 Enter three points for p0 p 1 and p2 11221515 15 15 is on the Me segment from 10 10 ...View the full answer
Answered By
Ankit Mahajan
I am an electrical engineering graduate from Thapar institute of engineering and technology.
Qualified exams - GATE 2019,2020.
CAT EXAM 2021- 91.4 percentile
SSC EXAMS- 2019,2020,2021
AFCAT EXAM- 2019,2020,2021
I want to share my knowledge with other people so that they can achieve the same.
I have strong hold Mathematics, Electrical engineering and all the subjects related.
Just give me a problem and I will give you the solution of it.
5.00+
1+ Reviews
10+ Question Solved
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Question Posted:
Students also viewed these Computer science questions
-
Write a program that prompts the user to enter three strings. Compare the String objects lexicographically and print the middle-valued string. For example, if the three strings were "abcd", "wxyz",...
-
Here are schematic diagrams of mutant larvae. The left side of each pair shows a wild-type larva, with gray boxes showing the sections that are missing in the mutant larva. Which type of gene is...
-
A researcher wants to test whether a certain sound will make rats do worse on learning tasks. It is known that ordinary rats can learn to run a particular maze correctly in 18 trials, with a standard...
-
In his book, The Federal Land Revisited, Marion Clawson proposed what he called the pullback concept: Under the pullback concept any person or group could apply, under applicable law, for a tract of...
-
What is the bit string corresponding to the difference of two sets?
-
Will you try to counter her cost argument? If so, how?
-
Why are long-term liabilities carried on the balance sheet at an estimate of present value, while long-lived assets are not?
-
RKO Company sold bonds with a face value of $850,000 for $910,000. The bonds have a coupon rate of 8 percent, mature in 10 years, and pay interest annually every December 31. All of the bonds were...
-
Pastner Brands is a calendar-year firm with operations in several countries. As part of its executive compensation plan, at January 1, 2021, the company issued 280,000 executive stock options...
-
Using examples, identify the main value-adding characteristics of the internet for e-business.
-
Suppose that the tuition for a university is $10,000 this year and increases 5% every year. In one year, the tuition will be $10,500. Write a program that computes the tuition in ten years and the...
-
Write a program that displays all possible combinations for picking two numbers from integers 1 to 7. Also display the total number of all combinations. 1 2 1 3 The total number of all combinations...
-
Exactly three out of four offspring are tall. Suppose that the allele A for height is dominant, meaning that plants with genotypes AA and Aa are tall, while those with genotype aa are short. If an Aa...
-
6 . A cylindrical furnace is operating at a temperature of 1 2 0 0 K and is emitting radiation uniformly in all directions. The inside diameter of the furnace is 2 m and the length of the furnace is...
-
How trade creates value ( Chapter 2 ) Max Daily Production Steaks Shrimp ( lbs . ) Fry Daddy 5 0 2 0 0 Grill Master 4 0 8 0 Refer to the above production data table for Fry Daddy and Grill Master....
-
Compounds A and B have the following vapor pressures: 150 o F: PA=600mmHg PB=500mmHg 200 o F: PA=1000mmHg PB=950mmHg Assume that these compounds form ideal solution, calculate the...
-
What makes a set of objects a vector space? You will no doubt want to refer to notes and the text, but I'd like you to summarize it for starters. If you have identified a vector space, for example...
-
Walla Walla Company is in its planning stage for next year. Walla Walla expects a big Quarter 3 and is creating a production budget to determine if it needs to hire more employees. Walla Walla knows...
-
Why are certain acts crimes in one state but not in another? Why are there varying levels of punishment for the same crime in different states?
-
Ball bearings are widely used in industrial applications. You work for an industrial food machinery manufacturer and your role is to design the driveshaft assembly on a new type of equipment that...
-
a. Sammys Seashore Supplies rents beach equipment such as kayaks, canoes, beach chairs, and umbrellas to tourists. You created a Rental class for the company. Now, make the following change to the...
-
A structure that allows repeated execution of a block of statements is a ____________. a. Cycle b. Ring c. Loop d. Band
-
A loop that never ends is a(n) ____________loop. a. Infinite b. Iterative c. Structured d. Illegal
-
Delaying the payment of accrued expenses until a later period is a technique that management can use to manipulate the current years cash flow from operating activities. True or False
-
Davis Company currently buys a component part for $6.10 per unit. Davis estimates that making the part would require $4.60 per unit of direct materials and $2.10 per unit of direct labor. Davis...
-
If a company has an opportunity to invest $85000 now for 14 years at 18% per year simple interest or 10% per year compound interest, which investment should be made?
Study smarter with the SolutionInn App