CS 150 - Intro to Programming - Fall 2001

| CS150 | Labs | Projects | Assignments | CodeSamples | Help Resources | Style Guide |


Programming Project 1

Due: Thursday, September 13th by 1:45pm

A point in a plain can be represented by giving it's x and y coordinates. A line segment can be represented by giving the two end points. A common task is to find the midpoint of a line segment given the two end points. The midpoint formula is given below:

Given two points (x1, y1) and (x2, y2) - the midpoint formula is:
xm = x2 + ((x1 - x2) / 2) and ym = y2 + ((y1 - y2) / 2)


Design, implement and test a C++ program that reads in two points (x and y coordinates) and calculates the midpoint of the line segment.

Sample program run:

Welcome to the midpoint calculator program!!
Enter coordinates for point 1 (x coordinate first): 3 3
Enter coordinates for point 2 (x coordinate first): -1 1
//output
With point 1 equal to (3,3) and point 2 equal to (-1,1)
The midpoint is (1,2).
Thanks for using the midpoint calculator

Notes:

What to Turn In:

electronic version files:

paper version: