Question: 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: 1. vertical line and vertical line segment 2. vertical line and non-vertical line segment 3. non-vertical line and vertical line segment 4. non-vertical line and non-vertical line segment Create a project and class named HW5FirstnameLastname in NetBeans using your actual first and last names to hold your program.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
