Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design an algorithm that takes pairs of points as input and finds the slope of t

ID: 3622863 • Letter: D

Question

Design an algorithm that takes pairs of points as input and finds the slope of the line that passes through each pair of points. The algorithm should prompt for a pair of points to be entered by the user. For each pair of points, after the slope is calculated, the algorithm should output the pair of points and the corresponding slope. All of the calculations related to the slope and the corresponding output should be done in a sub-algorithm. The algorithm should be able to handle any number of pairs of points. It should stop when the most recent value for x1 is a non-numeric character. However, prior to stopping the algorithm should output the number of pairs of points for which the slope has been calculated.

Explanation / Answer

please rate - thanks

M1. Set total pairs to 0
M2. Prompt for and get X1
M3. Repeat steps M4 to M9 until X1 is non numeric
M4. Prompt for and get Y1
M5. Prompt for and get X2
M6. Prompt for and get Y2
M7. Perform the Slope Calculation Sub-Algorithm
M8. Add 1 to the total pairs counter
M9. Prompt for and get X1
M10. Write the total pairs
M20. Stop

Slope Calculation Sub-Algorithm
S1. Calculate numerator as Y2-Y1
S2. Calculate denominator as X2-X1
S3. Calculate slope as numerator/denominator
S4. Output the slope



Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote