UMBC CMSC 104 * CSEE | 104 | current 104 

Project 1 - Slope of a Line

Due Date: Midnight Wednesday November 8, 2000

NO LATE PROJECTS WILL BE ACCEPTED!

Point Value

This assignment is worth 25 points.

Assignment

In a 2-dimensional plane, points are specified by their x- and y-coordinates.  A line is represented by any two points on the line
-- P1 (x1, y1) and P2 (x2, y2).  The slope of the line indicates how steeply the the line goes up and down and how it is
oriented in the plane.  The slope of the line can be calculated from any two points on the line. The slope of the line designated by the points P1 and P2 above is given by the formula

                slope = ( y2 - y1 ) / (x2 - x1)

assuming that  x2 > x1.

Your assignment is to write a program that inputs the x- and y-coordinates of two points on a line, then
calculates and displays the slope of that line with 2 digits behind the decimal point

The output from your program should look EXACTLY like the bolded text in the sample run given below. Also make sure that the spacing of the output (i.e., blank lines and blanks spaces) is EXACTLY like the spacing in the sample run.

This is the Slope Program

Enter the x-coordinate of P1:  5.3
Enter the y-coordinate of P1:  2.2
Enter the x-coordinate of P2:  7.3
Enter the y-coordinate of P2:  4.4

The line specified by the points (5.3, 2.2)  and  (7.3, 4.4) is 1.10
 

Your program may assume that the user will choose valid values for all inputs.  In particular, your program may assume that x2 (the x-coordinate of P2) will be greater than x1 (the x-coordinate of P1).  Use floating point variables for your program. Make sure to test your program by running it several times with different values for the coordinates. Verify the results by using a calculator. (Note that the last few digits for each value may differ when using a calculator. That is OK.)
 

Coding Standards

Note that you MUST adhere to the coding standards and indentation style given on the Projects home page. So read them carefully and immediately!
In addition, your file header comment (spelled out in the coding standards) must include your algorithm.

Project Submission

Submit your project by e-mailing your source code (slope.c) to Jason (cai1@gl.umbc.edu) as an attachment. Make the Subject of the e-mail Project 1 so that Jason knows what it is. Do NOT send your executable file (a.out).
 

Compiling your program

Remember to develop, compile and test your program on either linux1.gl.umbc.edu or linux2.gl.umbc.edu.
To compile your program, excute the command

                gcc -Wall slope.c

(there is no space between the - and the W)