Lab 3.1 - Slope Calculator

slope

The slope of a line is equal to the quotent of the rise and the run, which is to say something like (Y2 - Y1) / (X2 - X1). This number is rarely an integer, so it's useful to have a quick and easy way of calculating it.

Create an application that takes the X and Y coordinates of two points on a line and displays the slope in decimal form.

Look! It's a bird! It's a plane! It's an object list!

WARNING: Remember that a vertical line (one where both points' X-coordinates are the same) has no slope. The computer will give you a bad answer if it tries to divide by zero, so make sure your program checks for that before telling it to divide by (X2 - X1); the computer will have to make a decision about whether it can do the division before actually doing it. If your answer is "NaN" or "Infinity" or "-Infinity" then you're doing it wrong.

Here's sample data and answers that you should get:
X1 Y1 X2 Y2 Result
8 6 12 18 3
-3 5 85 -42 -0.534090909091
6 -3 6 19 Undefined
4 10 13 1320 145.5555555555556

OPTION: Come up with a method to also display the answer as a fraction. Five tokens to the first player who figures it out.

As always, design a useful and proper interface.