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: 45% (11 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?
-
With the exception of compasses, you seldom see or personally experience forces due to the Earth's small magnetic field. To illustrate this, suppose that in a physics lab you rub a glass rod with...
-
What do you know about the mathematical value of a project's internal rate of return under each of the following conditions? a. The present worth of the project is greater than 0 . b. The present...
-
The Derby Shoe Company produces its famous shoe, the Divine Loafer, which sells for $ 70 per pair. Operating income for 2012 is as follows: Sales revenue ($ 70 per pair)..... $ 280,000 Variable cost...
-
Please convert this E-R diagram to Relational model. Production Fixed Expenses FixedExpenseID DatePaid Description Amount Category Item Show/Production ShowID Actors Budget SetBudget OpiningDate...
-
1. Corbin was named as executor in his fathers will. While going through his late fathers papers, he discovered a promissory note made by Fulsom in the amount of $ 10,000 that reflected a personal...
-
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...
-
Horizon Communications has the following stockholders equity on December 31, 2016: Stockholders' Equity Paid-In Capital: Preferred Stock4%, $11 Par Value; 150,000 shares authorized, 22,000 shares...
-
The Problems of Multitasking An eastern U.S. financial services company found itself way behind schedule and over budget on an important strategic program. Both the budget and schedule baselines had...
-
Identify changes in two variables that would shift the supply curve of dollars to the right. Identify changes in two variables that would shift the demand curve for dollars to the right.
-
A 0.5-kg cart moving on a horizontal frictionless track at 0.6 m/s hits a solid bumber and bounces back with a speed of 0.4 m/s. The impulse on the cart is?
-
Last year many employers were offering sign up or early bonuses, free luch program, gas cards, flexible work time etc. many perks to their employees. If your employer offered you some of these perks,...
-
Explain what happens to the inflation, unemployment, and output gap in the short run in each of the following circumstances. do not need to graph but explain which part of IS/MP/PC is affected and...
-
Distinguish between independence in fact and independence in appearance. State three activities that may not affect independence in fact but are likely to affect independence in appearance.
-
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
-
You are given the following ODE: y+3y+2y+ y = 3x 1. Derive the frequency response function G(jw) of this ODE. 2. Calculate the magnitude of G(jw). 3. Calculate the phase of G(jw). 4. Calculate the...
-
Calculate the moment of inertia in terms of a and b according to the x-axis of the area in the figure -a- y=k(x-a)3 20 b
-
A premium annual - pay bond pays a $ 8 2 coupon, has a yield to maturity of 5 . 1 7 % , and is priced at $ 1 , 0 9 3 . 9 8 . How many years till the bond matures? Answer in years to at least two...
Study smarter with the SolutionInn App