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 xy 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: and ;
whereas the line D is defined by and
Premises
For a line represented by two points: x y and x y the slope of such line, m is
determined by:
Given two lines with slopes m and m respectively, the lines are perpendicular if the
product of their slopes yields :
mmProgramming Assignment #
COSC Programming Fundamentals II
Dallas College Fall
Email me at FAHernandez@dcccdedu 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: x x; consequently: x x
Note: If one of the lines is found to be verticalhorizontal all the program needs to do is
check to see if the other line is horizontalvertical 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 #:
Sample Run #:
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 #
COSC Programming Fundamentals II
Dallas College Fall
Email me at FAHernandez@dcccdedu if you have any questions
Testing
Assume two lines are represented by their coordinates, as follows:
Line : x y and x y
Line : x y and x y
Given the following values, your program should produce the corresponding output:
Test Case x yx yx yx y Output
Lines are perpendicular
Lines are not perpendicular
Lines are perpendicular
Lines are not perpendicular
Lines are not perpendicular
Lines are perpendicular
Grading Criteria
Program Description:
Program uses only the integer type:
Check to avoid divide by zero error:
Accuracy of results:
Notes:
You may only use material from Chapters of the eTextbook; otherwise, your
program will not be accepted.
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
