logo CodeStepByStep logo


Language/Type: PHP basics variables
Author: Melissa Hovik (on 2018/01/05)

Write a function named calculate_line which calculates and returns the y value of the line represented with a given $x value, $m slope, and an intercept $b (as seen in the line equation of the form y = m x + b). The value should be returned as a double.

For example, a call of calculate_line(5, 2, 4) would return 14 because 14 = 2 * 5 + 4, a call to calculate_line(1, 2, 0) would return 2 because 2 = 2 * 1 + 0, and a call to calculateLine(1, 0.5, 2) would return 2.5 because 2.5 = 0.5 * 1 + 2.

Function: Write a PHP function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.