Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a method named closeEnough that takes 3 double parameters--a value, a targ

ID: 3611614 • Letter: W

Question

Write a method named closeEnough that takes 3 double parameters--a value, a target and atolerance. The method should return a boolean indicating whetherthe value is close enough to the target, based on the tolerance. Inother words, if the absolute distance of the value to the target isless than the tolerance, the value is considered to be "closeenough" to the target. A sample main isprovided to give context:


public static void main(String [] args){
   Scanner keybd = newScanner(System.in);
   System.out.print("Enter value, target, andtolerance,     
   separated by spaces: ");
   double value = keybd.nextDouble();
   double target = keybd.nextDouble();
   double tolerance = keybd.nextDouble();
   if closeEnough(value, target,tolerance)) {
      System.out.println("OK");
   }
}

Explanation / Answer

please rate - thanks import java.util.*; public class untitled1 { public static void main(String [] args) {    Scanner keybd = new Scanner(System.in);    boolean done=false;    do    {    System.out.print("Enter value, target, and toleranceseparated by spaces: ");    double value = keybd.nextDouble();    double target = keybd.nextDouble();    double tolerance = keybd.nextDouble();    if (closeEnough(value, target, tolerance)) {       System.out.println("OK");         done=true;        }    else        System.out.println("tryagain");    }    while(!done); } public static boolean closeEnough(double val, double tar, doubletol)    {if(Math.abs(val-tar)
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote