id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

perimeter


Define a function that when passed two integers representing the x and y intercepts of a line, returns the perimeter of the triangle formed by those two points and the origin (0, 0).

You can use Math.sqrt to find the square root of a number, and Math.abs to find the absolute value of a number.

The complexity of this question is in the research and analysis, not the implementation.


perimeter(3, 4) → 12.0
perimeter(8, -6) → 24.0
perimeter(-10, 10) → 34.14213562373095

...Save, Compile, Run (ctrl-enter)

double perimeter(int x, int y) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 4 Post-solution available

Copyright Nick Parlante 2017 - privacy