Question: Vertical Lines Additional Requirements Course Coding Conventions: organizations use coding conventions to ensure consistency in their programs and to facilitate code maintenance; in this course,

Vertical Lines Additional Requirements
Course Coding Conventions: organizations use coding conventions to ensure
consistency in their programs and to facilitate code maintenance; in this course, we will
start using the following:
Program Description: your program must have a comment at the top briefly
describing what the program does. Usually, one sentence is enough; for
example: This program calculates the area of a circle given its radius.
Variable naming: use lower camel case; do not use underscore. Example:
total Cost instead of total_cost.
Constant names: use all uppercase; use underscore to separate words.
Example: MAX_WIDTH
Grading Criteria
Program Description: 10%
Program follow course coding conventions: 10%
Program uses only the integer type: 25%
Check to avoid divide by zero error: 25%
Accuracy of results: 30%
Notes:
You may only use material from Chapters 1-3 of the eTextbook; otherwise, your
program will not be accepted.
Programs with syntax errors will not be accepted.
Email me at
FAHernandez@dcccd.edu if you have any questions Programming Assignment #1
COSC-1437- Programming Fundamentals II
Dallas College - Fall 2024
Instructions
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 AB is defined by the pairs: (15,10) and (49,25); whereas the line CD 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:
m=y2-y1x2-x1
Given two lines with slopes m 1 and m 2 respectively, the lines are perpendicular if the product of their slopes yields -1 :
(m1)(m2)=-1
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"
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 output
should be one of the two shown above.
Sample program output
Sample Run #1:
Enter coordinates (x1,y1,x2,y2) for the first line: 1551531
Enter coordinates (x3,y3,x4,y4) for the second line: 9163516
Lines are perpendicular
Sample Run #2:
Enter coordinates (x1, y1, x2, y2) for the first line: 13205120
Enter coordinates (x3,y3,x4,y4) for the second line: 14102635
lines are not perpendicular
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: do this in java
Vertical Lines Additional Requirements Course

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!