(General math) Modify the program written for Exercise so that it accepts the x- and y-coordinates of two points. Have your program determine and display the midpoints of the two points (using the formula given in Exercise). Verify your program by using the following test data:
Test data set 1: Point 1 = (0,0) and Point 2 = (16,0)
Test data set 2: Point 1 = (0,0) and Point 2 = (0,16)
Test data set 3: Point 1 = (0,0) and Point 2 = (-16,0)
Test data set 4: Point 1 = (0,0) and Point 2 = (0,-16)
Test data set 5: Point 1 = (-5,-5) and Point 2 = (5,5)
When you have finished your verification, use your program to complete the following chart:
First Point | Second Point | Midpoint |
(4,6) | (16,18) |
|
(22,3) | (8,12) |
|
(-10,8) | (14,4) |
|
(-12,2) | (14,3.1) |
|
(3.1,-6) | (20,16) |
|
(3.1,-6) | (-16,-18) |
|
Exercise:
(General math)
a. Write a C++ program to calculate and display the midpoint coordinates of the line segment connecting the two endpoints given in Exercise a. Use the fact that the coordinates of the midpoint between two points with the coordinates (x1,y1) and (x2,y2) are ((x1 + x2) / 2, (y1 + y2) / 2). Your program should produce the following display (replacing the underscores with values your program calculates):
The x midpoint coordinate is _____
The y midpoint coordinate is _____
b. How do you know the midpoint values your program calculates are correct?
c. After verifying the output your program produces, modify it to determine the midpoint coordinates of the line connecting the points (2,10) and (12,6).
d. If your program doesn’t already do so, change its output to this:
The x coordinate of the midpoint is xxx.xx
The y coordinate of the midpoint is xxx.xx
The xxx.xx denotes placing the calculated value in a field wide enough for three places to the left of the decimal point and two places to the right of it.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.