# How it works

## Q1- How many types of slope calculations do we have?

In this slope calculator, you can find the slope by two different methods of slope calculations

1. Two Points

2. Line Equations

By default, we set our calculator for two points of the slope. But if you want to change, just select your desired type of slope calculation from the dropdown and it will show you the required input fields for calculations below the dropdown.

## Q2- How do we take user inputs?

After selecting the slope calculation’s type you will have required input fields where you write your points or equation’s coefficients. According to this slope calculator, we change input fields magically in milliseconds using JS(Javascript) by a just selection of slope calculation types from the dropdown.

### Inputs of two points slope

As in this method of the slope, we have x-axis (X1, X2) and y-axis (Y1, Y2) coordinate points. In this calculator, we have a total of four input fields, two for the X-coordinate and two for the Y-coordinate.

### Inputs of a line equation slope

According to this method of slope line equation, we have an equation with blank input fields of coefficients like values of X, Y and C. Just enter your coefficients and get your accurate answer and solution steps.

## Q3-  How do we validate user inputs?

Validation is a very important part of calculations. In this Slope Calculator, we make more efficient and intelligent input fields that only allow numbers, decimals, or negative numbers using Javascript magical functions. The user cannot enter any character, comma, extra negative sign, extra dots(decimals), etc.

## Q4- How do we calculate the slope and its solution steps?

In this calculator after taking and validating inputs in Html and javascript when the user clicks on the calculate button, we send values to server script (PHP) where we do some more magical calculations.

Firstly our PHP code checks what type of slope calculation you select from the dropdown. In PHP we calculate the slope in steps

Like

1. Find delta

2. Finding percentage grade divide rise(delta_y) by run(delta_x) and multiply with 100

3. Finding slope(m)

4. Finding distance

5. Finding degrees

6. Finding y-intercept with point (x1,y1)

7. Formula y = mx+b put x=0 to find y_intercept

8. Formula y = mx+b put y=0 to find x_intercept

9. Returning all calculations to javascript

10. Javascript show all value in frontend

## Q5- How do we show the answer and solution steps to the user?

After receiving the results response from PHP in Javascript we have multiple objects with answers. Using javascript append and text functions we show all answers in Html.

## Q6- How do we create graphs according to user inputs?

We use a third party to create graph jsxgraph.org