Source of MathTest.java


  1: // Exercise 6.3: MathTest.java
  2: // Testing the Math class methods.
  3: 
  4: public class MathTest 
  5: {
  6:    public static void main( String args[] )
  7:    {
  8:       System.out.printf( "Math.abs( 23.7 ) = %f\n", Math.abs( 23.7 ) );
  9:       System.out.printf( "Math.abs( 0.0 ) = %f\n", Math.abs( 0.0 ) );
 10:       System.out.printf( "Math.abs( -23.7 ) = %f\n", Math.abs( -23.7 ) );
 11:       System.out.printf( "Math.ceil( 9.2 ) = %f\n", Math.ceil( 9.2 ) );
 12:       System.out.printf( "Math.ceil( -9.8 ) = %f\n", Math.ceil( -9.8 ) );
 13:       System.out.printf( "Math.cos( 0.0 ) = %f\n", Math.cos( 0.0 ) );
 14:       System.out.printf( "Math.exp( 1.0 ) = %f\n", Math.exp( 1.0 ) );
 15:       System.out.printf( "Math.exp( 2.0 ) = %f\n", Math.exp( 2.0 ) );
 16:       System.out.printf( "Math.floor( 9.2 ) = %f\n", Math.floor( 9.2 ) );
 17:       System.out.printf( "Math.floor( -9.8 ) = %f\n", 
 18:          Math.floor( -9.8 ) );
 19:       System.out.printf( "Math.log( Math.E ) = %f\n", 
 20:          Math.log( Math.E ) );
 21:       System.out.printf( "Math.log( Math.E * Math.E ) = %f\n", 
 22:          Math.log( Math.E * Math.E ) );
 23:       System.out.printf( "Math.max( 2.3, 12.7 ) = %f\n",
 24:          Math.max( 2.3, 12.7 ) );
 25:       System.out.printf( "Math.max( -2.3, -12.7 ) = %f\n",
 26:          Math.max( -2.3, -12.7 ) );
 27:       System.out.printf( "Math.min( 2.3, 12.7 ) = %f\n",
 28:          Math.min( 2.3, 12.7 ) );
 29:       System.out.printf( "Math.min( -2.3, -12.7 ) = %f\n",
 30:          Math.min( -2.3, -12.7 ) );
 31:       System.out.printf( "Math.pow( 2.0, 7.0 ) = %f\n",
 32:          Math.pow( 2.0, 7.0 ) );
 33:       System.out.printf( "Math.pow( 9.0, 0.5 ) = %f\n", 
 34:          Math.pow( 9.0, 0.5 ) );
 35:       System.out.printf( "Math.sin( 0.0 ) = %f\n", Math.sin( 0.0 ) );
 36:       System.out.printf( "Math.sqrt( 900.0 ) = %f\n", 
 37:          Math.sqrt( 900.0 ) );
 38:       System.out.printf( "Math.sqrt( 9.0 ) = %f\n", Math.sqrt( 9.0 ) );
 39:       System.out.printf( "Math.tan( 0.0 ) = %f\n", Math.tan( 0.0 ) );
 40:    } // end main
 41: } // end class MathTest
 42: 
 43: /**************************************************************************
 44:  * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and               *
 45:  * Pearson Education, Inc. All Rights Reserved.                           *
 46:  *                                                                        *
 47:  * DISCLAIMER: The authors and publisher of this book have used their     *
 48:  * best efforts in preparing the book. These efforts include the          *
 49:  * development, research, and testing of the theories and programs        *
 50:  * to determine their effectiveness. The authors and publisher make       *
 51:  * no warranty of any kind, expressed or implied, with regard to these    *
 52:  * programs or to the documentation contained in these books. The authors *
 53:  * and publisher shall not be liable in any event for incidental or       *
 54:  * consequential damages in connection with, or arising out of, the       *
 55:  * furnishing, performance, or use of these programs.                     *
 56:  *************************************************************************/