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

 

abraskin@mbusd.org > distance
prev  |  next  |  chance

A point can be represented as an x and y coordinate.


The parameters to the distance method include two points so the parameters are x1, y1, x2, y2 where the first two parameters are the coordinates of the first point and the second two parameters the coordinates of the second point.

Complete the distance method so it returns the distance between the two points.

distance(1, 1, 5, 1) → 4.0
distance(1, 1, 1, 5) → 4.0
distance(-3, 0, 2, -3) → 5.830951894845301

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

public double distance(double x1, double y1, double x2, double y2) { }

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: 200 Post-solution available

Copyright Nick Parlante 2017 - privacy