Topical Information

This program works with more data to give you some more practice at handling more variables. It will hopefully also give you an even better feel for how much testing is necessary to verify a program's correctness. Finally, it gives a refresher to some concepts from algebra.

Program Information

Write a program that helps the user calculate the midpoint of a line segment in the 2D Cartesian plane. Try to make your results as readable as possible.


As an example, you might have the program interaction look something like (the parts in this color are typed by the user):

$ ./midpoint.out

                 Welcome to the 2D Midpoint Program!!!

What is the first end-point?  3.4 12.2
What is the second end-point?  13.4 12.2

Thank you!!  Calculating...  Done.

The midpoint of the line segment between (3.4, 12.2) and (13.4, 12.2)
is (8.4, 12.2).

Thank you for using the TMP!!

Endeavor to have a voracious day!

$

Thought Provoking Questions

  1. How many variables are needed here? (Hint: There are two points being input and a third point being output. How many values are needed to 'make' a 2D point?)
  2. Would it make any sense to have whole-valued point coordinates (as opposed to decimal-valued point coordinates...)? That is, would it ever be correct for you to assume that a point's coordinates would never have fractional parts?
  3. What is the formula to calculate a midpoint? Compare/Contrast the x part of the formula and the y part. (I.E. How are they similar? How are they different?)
  4. What happens if the input points are in different quadrants? In the same quadrant? On an axis? At the origin? (I.E. Can your program ever go wrong because of the points' locations?)
  5. How many different ways can you pick a pair of points from the Cartesian plane: quadrant(s), axis/axes, origin? (In other words, how many tests would it take to completely test your program?) (You do not have to script that many tests. But you should be able to calculate how many there should be. That way when you are working in industry, you can more thoroughly test your applications and run Micro-sloth out of business. *chuckle* *grin*)

This assignment is (Level 1.5).


Options


Total Level Possible

If you did all above options, this lab could be worth as much as (Level 2.5).