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

 

isSquareRoot


Complete the function squareRoot that will result in the following solution of isSquareRoot to pass the tests provided. Of course, you shouldn't use Math.sqrt(). Due to the nature of codingbat, you need to copy the partially-completed template below into the answer box first.

boolean isSquareRoot(double a, double b) {
   double root = squareRoot(a);
   if(Math.abs(a - b*b) <= a/100.0) {
      return true;
   }
   return false;
}

double squareRoot(int val) {
   //to be completed
}

isSquareRoot(10.5, 3.24) → true
isSquareRoot(1729.6174, 41.58) → true
isSquareRoot(10.5, 3.23) → true

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

boolean isSquareRoot(double a, double b) { }

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

Copyright Nick Parlante 2017 - privacy