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

 

gaurav.gupta@mq.edu.au loops > isSquareRoot
prev  |  next  |  chance

Complete the function squareRoot that will result in the following solution of isSquareRoot to pass the tests provided. Due to the nature of codingbat, you need to copy the partially-completed template below into the answer box first.

//BEGIN BOILERPLATE/STARTING-POINT

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
}

//END BOILERPLATE/STARTING-POINT

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

Copyright Nick Parlante 2017 - privacy