Question: Write a Java program to determine whether two straight lines are perpendicular. The program must prompt the user for the values of x - y

Write a Java program to determine whether two straight lines are perpendicular. The
program must prompt the user for the values of x-y coordinates for two points of each
line. Coordinate figures must be read as integers.
Example: in the graph below, the line B is defined by the pairs: (15,10) and (49,25);
whereas the line D is defined by (29,5) and (32,32).
Premises
For a line represented by two points: (x1, y1) and (x2, y2), the slope of such line, m, is
determined by:
=
Given two lines with slopes m1 and m2 respectively, the lines are perpendicular if the
product of their slopes yields -1:
(m1)(m2)=-1Programming Assignment #1
COSC-1437 Programming Fundamentals II
Dallas College - Fall 2024
Email me at FAHernandez@dcccd.edu if you have any questions
Vertical Lines
The program should avoid a divide by zero error by checking for vertical lines. In a
vertical line: x2= x1; consequently: x2 x1=0.
Note: If one of the lines is found to be vertical/horizontal, all the program needs to do is
check to see if the other line is horizontal/vertical to determine whether they are
perpendicular or not.
Output
The program output should be either:
Lines are perpendicular
Or
Lines are not perpendicular
Sample program output
Sample Run #1:
Sample Run #2:
The program should not produce any other output. For example, if the program
detects a vertical line, do not display: Divide by zero error and exit. Instead, the outputt
should be one of the two shown above.Programming Assignment #1
COSC-1437 Programming Fundamentals II
Dallas College - Fall 2024
Email me at FAHernandez@dcccd.edu if you have any questions
Testing
Assume two lines are represented by their coordinates, as follows:
Line 1: (x1, y1) and (x2, y2)
Line 2: (x3, y3) and (x4, y4)
Given the following values, your program should produce the corresponding output:
Test Case (x1, y1)(x2, y2)(x3, y3)(x4, y4) Output
1(13,20)(51,20)(25,7)(25,35) Lines are perpendicular
2(13,20)(51,20)(14,10)(26,35) Lines are not perpendicular
3(15,5)(15,31)(9,16)(35,16) Lines are perpendicular
4(13,20)(51,20)(14,10)(26,35) Lines are not perpendicular
5(21,7)(49,27)(26,35)(38,10) Lines are not perpendicular
6(10,10)(35,35)(15,35)(35,15) Lines are perpendicular
Grading Criteria
1. Program Description: 10%
2. Program uses only the integer type: 30%
3. Check to avoid divide by zero error: 30%
4. Accuracy of results: 30%
Notes:
1. You may only use material from Chapters 1-3 of the eTextbook; otherwise, your
program will not be accepted.
2. Programs with syntax errors will not be accepted.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!