/** 9/12/2018
  * This program introduces the Math class from the Java API.
  * We used this class to introduce methods in Java, parameters, and return
  * values. 
  */

public class MathClass
{
/**
 * This example source code demonstrates the use of  
 * Random() method of Math class
 * Generating random numbers from 1 to 10
 */
 public static void main(String[] args) 
 {
  int num = -5;
  System.out.println("Absolute value of " + num + " is: " + Math.abs(num));
  int test1=87, test2=91;
  double avg = Math.addExact(test1, test2)/2; // method call is embedded in an expr
  System.out.println("Test average " + avg);
  
  // generate random number from 1 to 100
  // casting is a forced conversion (here we are converting double to int)
  // all data after decimal point is TRUNCATED or cut off. Not rounded.
  int rand =  (int) (Math.random() * 100) + 1;
  System.out.println(rand);
 }
}
