Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java program that reads a line and a line segment and then determines whether they intersect or not. When they overlap completely, consider

Write a Java program that reads a line and a line segment and then determines whether they intersect or not. When they overlap completely, consider that as intersecting. Use variables ((lp1x, lp1y), (lp2x, lp2y)) to represent a line and ((sp1x, sp1y), (sp2x, sp2y)) to represent a line segment. Some examples:

((lp1x, lp1y), (lp2x, lp2y)) ((sp1x, sp1y), (sp2x, sp2y)) outputs

((0, 0), (5, 4)) ((4, 0), (0, 4)) intersecting

((0, 0), (5, 5)) ((1, 1), (4, 4)) intersecting

((2, 1), (6, 1)) ((4, 1), (5, 4)) intersecting

((0, 0), (5, 4)) ((2, 0), (4, 1)) non-intersecting

((1, 1), (1, 4)) ((2, 3), (5, 3)) non-intersecting

Divide the problem into four cases using a nested if statement after checking on the inputs:

vertical line and vertical line segment

vertical line and non-vertical line segment

non-vertical line and vertical line segment

non-vertical line and non-vertical line segment

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

3. Is there opportunity to improve current circumstances? How so?

Answered: 1 week ago