AP Computer Science --- Haas --- DoubleCompare

Complete the following class which determines if two decimal numbers are equal when rounded to a given number of decimal places.



/**
*   This class is used to determine whether two floating-point numbers are the same
*   when rounded to a given number of decimal places.
*/
public class DoubleCompare
{
  /**
   * Zero argument constructor    
   **/
   public DoubleCompare()
   {
   }

  /** >>>> complete this method <<<<<<
   *  Method to test the equality of the two inputs.
   *  @param num1 is the first number
   *  @param num2 is the second number
   *  @param places is the number of places AFTER the decimal point
   *  @return true if the two numbers are the same up to the given 
   *  number of places, else return false
   */
   public boolean isSameNumber(double num1, double num2, int places)
   {
     // <<<<<<<<<<<<<<<<<< Complete this method >>>>>>>>>>>>>>>>>
   }
}




/*************************************************************
* Complete this tester for the class DoubleCompare.
***************************************************************/
public class DoubleCompareTester
{
   public static void main(String[] args)
   {
      
      // Create an object of type DoubleCompare,
      // then use the method isSameNumber to test if numbers 
      // are equal for a given number of places.
      // Example:        
      //   numbers 1.9998 and 2.0000 to 3 places prints true
      //   numbers 1.9998 and 2.0000 to 4 places prints false


           <<<<<< complete the code >>>>>>>
      
   }
}