about | help | code help+videos | done | prefs |
Equation of a line is given as y = mx + b, where m is the gradient (angle) and b is the y-intercept at x=0. Define a function that given two points through which line passes, returns the gradient of the line. Return null if it is a vertical line (hence, the return type Double) If you don't have the required math knowledge, refer to this page: See this to further understand this: https://www.mathsisfun.com/equation_of_line.html gradient(10, 5, 7, 4) → 0.3333333333333333 gradient(5, 8, -1, 20) → -2.0 gradient(10, 0, 10, 20) → null ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 3 Post-solution available
Copyright Nick Parlante 2017 - privacy