// Demo for Math Class functions
// Author: Michael S. Branicky, 09/05/2006
// Cf. Figure 6.2 of Deitel & Deitel, Java How to Program, 6/e

public class MathDemo {
  public static void main (String args[])
  {
    System.out.println("Value of constant pi:    " + Math.PI);
    System.out.println("Value of constant e:     " + Math.E);

    System.out.println("Absolute value of 23.7:  " + Math.abs(23.7));
    System.out.println("Absolute value of 0.0:   " + Math.abs(0.0));
    System.out.println("Absolute value of -23.7: " + Math.abs(-23.7));

    System.out.println("Ceiling of 9.2:          " + Math.ceil(9.2));
    System.out.println("Ceiling of -9.8:         " + Math.ceil(-9.8));

    System.out.println("Cosine of 0.0:           " + Math.cos(0.0));
    System.out.println("Cosine of pi/2:          " + Math.cos(Math.PI/2.0));

    System.out.println("Exponential of 0.0:      " + Math.exp(0.0));
    System.out.println("Exponential of 1.0:      " + Math.exp(1.0));
    System.out.println("Exponential of 2.0:      " + Math.exp(2.0));
    System.out.println("Exponential of -1.0:     " + Math.exp(0.0));

    System.out.println("Floor of 9.2:            " + Math.floor(9.2));
    System.out.println("Floor of -9.8:           " + Math.floor(-9.8));

    // It repeats: a constant in calculus, a constant in calculus
    System.out.println("Natural log of e:        " + Math.log(Math.E));
    System.out.println("Natural log of e^2:      " + Math.log(Math.E*Math.E));

    System.out.println("Max of 2.3 and 12.7:     " + Math.max(2.3, 12.7));
    System.out.println("Max of -2.3 and -12.7:   " + Math.max(-2.3, -12.7));

    System.out.println("Min of 2.3 and 12.7:     " + Math.min(2.3, 12.7));
    System.out.println("Min of -2.3 and -12.7:   " + Math.min(-2.3, -12.7));

    System.out.println("2.0 raised to the 7.0:   " + Math.pow(2.0, 7.0));
    System.out.println("9.0 raised to the 0.5:   " + Math.pow(9.0, 0.5));

    System.out.println("Sine of 0.0:             " + Math.sin(0.0));
    System.out.println("Sine of pi/2:            " + Math.sin(Math.PI/2.0));

    System.out.println("Square root of 900.0:    " + Math.sqrt(900.0));
    // I have a root of a two, whose square is two
    System.out.println("Square root of 2.0:      " + Math.sqrt(2.0));
    System.out.println("Square root of -1.0:     " + Math.sqrt(-1.0));

    System.out.println("Tangent of 0.0:          " + Math.tan(0.0));
    System.out.println("Tangent of pi/4:         " + Math.tan(Math.PI/4.0));
    System.out.println("Tangent of pi/2:         " + Math.tan(Math.PI/2.0));
  }
}
