Help!

Write a boolean function to compute the slope (m) and y-intercept (b) of a line, given, as parameters, the two end points P1 = (x1, y1) and P2 = (x2, y2) of that line. The slope is computed as m = (y2 - y1) / (x2 - x1). The y-intercept is computed as b = y - mx. The resulting slope and y-intercept are to be passed back from the function via function parameters. Lastly, the function returns true if there are no issues while computing the slope or y-intercept. If there are issues, such as “bad” end points being passed to the function, then the function does not compute anything and instead only returns false.

Can someone please explain the math in this question to me, and based on that explanation, simply explain to me what it is this question is asking for in terms of coding.

Thanks
Last edited on
You are being asked to have a function that computes the given parameters x1,x2,y1,y2 to get the slope and y intercept. If you have taken any math course then you should know that x2-x1 can't be zero also any other other ways in which the equation could not exist. If everything is good then continue and finish computing. Have if and if-else statements to check when the values are bad and return the false boolean. Other than that boolean should be true from the beginning and only be false when it goes through the if statements.
Topic archived. No new replies allowed.