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

 

returnSpeed


Define a function that when passed three floating-point values, the first representing distance between two locations, the second representing the average speed of one-way trip, and the third representing the required average speed of the entire return-trip, returns the speed at which you must return to achieve the expected overall average.

For example, if A and B are 60 kms apart, you travel from A to B @ 30kmph, and the overall average speed should be 40kmph, then you must return from B to A @60kmph. We will let you work out the math.


returnSpeed(60, 30, 40) → 60.0
returnSpeed(100, 80, 90) → 102.85714285714285
returnSpeed(12, 9, 5) → 3.4615384615384612

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

double returnSpeed(double distance, double toSpeed, double requiredOverallSpeed) { }

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

Copyright Nick Parlante 2017 - privacy