# Slope-Intercept, Distance, and Midpoint Formula Program

One of the most common scenarios in basic algebra is the encounter of two coordinate points. You may need to determine an equation for the line connecting the two points. You might need the distance between the two points. You may also need to figure out the point which is an equal distance apart from both points — the midpoint. This simple program solves all three of those problems. To learn how to create the program, follow the detailed instructions, or jump directly to the completed code using the button below.

### Creating the Program

To create a program, press the *prgm* button and scroll over to **NEW**. You can name it whatever you like, but it’s wise to name it something related to its function. I will name it TWOPNTS due to the 8 character limit.

### Coding the Program

To start out, we need to clear the home screen, then prompt the user for the x and y values of both points. That is done using the *Input *command which is found by pressing the *prgm* button inside the code editor. Inside quotation marks, type what you wish to display to the user. After a comma, designate the variable to store the input value. The blank *Disp *statement is just used for aesthetics here.

`: ClrHome`

: Input "X1= ",A

: Input "Y1= ",B

: Disp ""

: Input "X2= ",C

: Input "Y2= ",D

Next, we should clear the home screen again to make space, and calculating and displaying all desired values. We can begin with a line equation. Use the variable names to calculate the slope and output the value after displaying its classification. The *Disp *command creates a new line with each placement. The *Output( *command can display something anywhere. For example. displaying “SLOPE=” creates a new line at the top of the screen and displays that text left to right. After calculating the slope value we can display it by outputting the value on the first line (1) and the eight position (8) which will create a space after the equal sign (because “SLOPE=” takes up 6 spaces). The next *Disp *statement which displays “Y-INT=” creates a second line so the corresponding output needs to start on line 2, and so on. Feel free to get creative on how to display all the values.

`: ClrHome`

: Disp "SLOPE="

: (D-B)/(C-A)→M

: Output(1,8,M)

: Disp "Y-INT="

: Output(2,8,B-MA)

: Disp "DIST="

: Output(3,7,√((C-A)²+(D-B)²))

: Disp "MID X="

: Output(4,8,(A+C)/2)

: Disp "MID Y="

: Output(5,8,(B+D)/2)

: Disp ""

### Running the Program

Your program should now be complete! Run the program and try testing the two points (3, 6) and (1, 4). It should tell you that the line y = x + 3 intersects both points, the distance between them is 2.83 units, and the midpoint is (2, 5). This program is not just handy for class but also most standardized tests such as the ACT or SAT which often have a few problems about these concepts.

### Complete Code

`: ClrHome`

: Input "X1= ",A

: Input "Y1= ",B

: Disp ""

: Input "X2= ",C

: Input "Y2= ",D

: ClrHome

: Disp "SLOPE="

: (D-B)/(C-A)→M

: Output(1,8,M)

: Disp "Y-INT="

: Output(2,8,B-MA)

: Disp "DIST="

: Output(3,7,√((C-A)²+(D-B)²))

: Disp "MID X="

: Output(4,8,(A+C)/2)

: Disp "MID Y="

: Output(5,8,(B+D)/2)

: Disp ""

## 0 Comments