// Lecture 6
class Lecture6 {
  public static void main(String[] args) {
    double i,j;
    long k;
    int x, y;
    // 1) the Math class
    // Math.abs(<varType> <varName>) : returns the absolute value as type varType of the input value
    //                                 where varType can be int, long, double or float.
    //     initialize i to -5, calculate the absolute value of i, and assign it to j.
    i = -5;
    j = Math.abs(i);
    //     now print it out.
    System.out.println("Using the Math.abs() method, the absolute value of " + i + " is " + j);
    // Math.floor(double <varName>) : returns the  largest (closest to positive infinity) double value 
    //                                that is not greater than the argument and is equal to a mathematical 
    //                                integer. 
    //    let i be 5.523, calculate the floor of i, then assign it to j
    i = 5.523;
    j = Math.floor(i);
    System.out.println("Using the Math.floor() method, the floor value of " + i + " is " + j);
    // Math.ceil(double <varName>) : returns the  smallest (closest to positive infinity) double value 
    //                                that is greater than the argument and is equal to a mathematical 
    //                                integer. 
    //    let i be 5.523, calculate the ceiling of i, then assign it to j
    i = -5.523;
    j = Math.ceil(i);
    
    
    System.out.println("Using the Math.ceil() method, the ceiling value of " + i + " is " + j);
    // Math.sqrt(double <varName>) : Returns the correctly rounded positive square root of a double value.
    //    let i be 9, calculate the square root of i, then assign it to j
    
//    System.out.println("Using the Math.sqrt() method, the square root of " + i + " is " + j);
    
    // Math.round(<vartype> <varName> : rounds to the closest integer and returns int when vartype is 
    //                                 float and long when vartype is double.
    // does it round up or down?
    //     let i be 5.5, round i and assign the rounded value to k, then print it out
    i = 5.5;
    k = Math.round(i);
    
    System.out.println("Using the Math.round() method, " + i + " rounds to " + k);
    // Other methods of interest:
    // Math.random() : Returns a double value with a positive sign, greater than or equal to 0.0 and less 
    //                 than 1.0. Returned values are chosen pseudorandomly with (approximately) uniform 
    //                 distribution from that range. 
    // Math.pow(double a, double b) :Returns the value of a raised to the power of b.) 
    // What are Math.PI and Math.E?
    // Math.cos(double a) :Returns the trigonometric cosine of a, an angle, in radians

    // 2) Boolean Operators and Expressions
    x = 5;
    y = 3;
    boolean result;
    result = x > y;
    System.out.println("x = " + x + ", y = " + y + ", x > y is " + result);
    result = x <= y;
    System.out.println("x = " + x + ", y = " + y + ", x <= y is " + result);
    double nbr2 = 2.0;
    double root2 = Math.sqrt(nbr2);
    i = root2 * root2;
    result = i == nbr2;
    System.out.println("the square root of 2.0, squared, equals 2.0: " + result);
    // machine epsilon
    
    
    // Relation operators: - less than, <
    //                       greater than, >
    //                       less than or equal to, <= 
    //                       greater than or equal to, >=
    //                       not equal to, !=
    //                       and equal to. ==
 
    //                     - The value on the left size is compared to the value on the right - evaluates    
    //                       the "relation" between these values.
    //                     - Can be applied to primitives only.  What happens when we compare strings?
    //                     - the same conversion rules apply when comparing different primitive types.
    //                     - evaluate to true or false - booleans
    // examples:
    
    // Boolean operators: and, <expression1> && <expression2> - true if both expression1 and expression2
    //                                                           are true.
    //                    or, <expression1> || <expression2> - true if either expression1 or expression2
    //                                                           are true or both are true.
    //                    not, !<expression> - true if expression is false, and false if expression is true.
    //                    - boolean operators are used with boolean expressions only.
    // When using the "and" operator, what will happen here ... why:
    x = 0;
    y = 3;
    //x == 0 && y == 3
    result = x != 0 &&  y/x > 3;
    System.out.println("x = " + x + ", y = " + y + ", x != 0 &&  y/x > 3 is " + result);
    
    
    // 3) if then else  *** discussion
    boolean pass = false;
    int mark = 52;
    int grade = 70;
    if (mark >= 50) {
      pass = true;
      grade++;
    }
    else
      pass = false; // you do not need braces for a single statement - but it makes good sense
                    // to use them: just in case you modify your code in the future.
         
  }
  
  
}