Lab 4 - Whose Line Is It Anyway?

 

Write a complete C++ program that when given the x and y coordinates of two points on a line, the program calculates and displays the slope and the midpoint of that line.  

 

Given two points (x1, y1) and (x2, y2) the formula for the slope of a line is:

 

 

 

The formula for the midpoint of a line is:

 

 

 

 

Your output should display the original two points, the slope and the midpoint in a clear organized manner.

 

Test your program with the following sets of points and two sets of your own choosing.  This means you must run your program

SIX times!!  You do not need to put each output on separate sheets of paper (Remember GREEN!!)

 

Point1

Point2

(4, 6)

(16, 18)

(4, 6)

(16, 19)

(-10, 8)

(14, 4.2)

(3.4, -6)

(20, 16)

 

Sample Output

 

Please enter the x coordinate of the first point on a line: 4

Please enter the y coordinate of the first point on a line: 6

Please enter the x coordinate of the second point on the line: 16

Please enter the y coordinate of the second point on the line: 18

 

The first point's coordinate is: (4,6)

The second point's coordinate is: (16,18)

The slope of the line is: 1

The midpoint is: (10,12)

 

IMPORTANT - Place the steps for the software development procedure in a comment at the top of your program.  Comment your code judiciously.

 

HAND IN - Your program along with the 6 sets of output produced.