/*
 *  =============================================================
 *  GettingStarted.java: Compute and print arithmetic expressions
 *
 *  Written By: Mark Austin                          October 2003
 *  =============================================================
 */

import java.lang.Math;
import java.text.*;

public class GettingStarted {

   // Constructor method.

   public GettingStarted() {};

   // main method : this is where the program execution begins.

   public static void main ( String [] args ) {

       // Define integer variable ......

       int    iA = 2;

       // Define floating point variables ......

       float  fB = 2.0F;
       double dC = 3.141592;

       // Print variables to default accuracy

       System.out.println("Print default values of variables");
       System.out.println(" iA = " + iA );
       System.out.println(" fB = " + fB );
       System.out.println(" dC = " + dC );

       // Format and print variables to two decimal places of accuracy

       System.out.println("Print formatted variable");

       DecimalFormat formatOutput = new DecimalFormat ("0.00");
       String output1 = formatOutput.format( dC );
       System.out.println(" dC = " + output1 );

       // Explore and print the range of variable values ....

       System.out.println("");
       System.out.println("Print booleans ..");
       boolean aTest = true;
       boolean bTest = false;
       System.out.println("boolean aTest = " + aTest );
       System.out.println("boolean bTest = " + bTest );

       System.out.println("");
       System.out.println("Print range of integers ..");
       int   iBig = Integer.MAX_VALUE;
       System.out.println("Maximum integer = " + iBig );
       System.out.println("Ninimum integer = " + Integer.MIN_VALUE );

       System.out.println("");
       System.out.println("Print range of floating point nos ..");

       float fBig = Float.MAX_VALUE;
       System.out.println("Maximum float  = " + fBig );
       System.out.println("Minimum float  = " + Float.MIN_VALUE );

       double dBig = Double.MAX_VALUE;
       System.out.println("Maximum double = " + dBig );
       System.out.println("Minimum double = " + Double.MIN_VALUE );

       // Basic arithmentic expressions ....

       System.out.println("\nBasic arithmetic expressions ..");
       System.out.println("Addition:         2 + 3 = " + (2 + 3));
       System.out.println("Subtraction:      2 - 3 = " + (2 - 3));
       System.out.println("Multiplication: 2 + 3*5 = " + (2 + 3*5));

       // Using the modulo operator ....

       System.out.println("\nUse of the modulo operator ..");
       System.out.println("Remainder     : 10%3 = " + 10%3 );
       System.out.println("Remainder     : 11%3 = " + 11%3 );
       System.out.println("Remainder     : 12%3 = " + 12%3 );
       System.out.println("Remainder     : 13%3 = " + 13%3 );

       // Integer division in Java ....

       System.out.println("\nDivision of integers in Java ..");
       System.out.println("Integer division: 1/3 = " + (1/3) );
       System.out.println("Integer division: 2/3 = " + (2/3) );
       System.out.println("Integer division: 3/3 = " + (3/3) );
       System.out.println("Integer division: 4/3 = " + (4/3) );
       System.out.println("Integer division: 5/3 = " + (5/3) );

       // Floating-point division in Java ....

       System.out.println("\nDivision of floating point numbers ...");
       System.out.println("Division: 1/3. = " + (1/3.) );
       System.out.println("Division: 2./3 = " + (2./3) );
       System.out.println("Division: 3./3 = " + (3./3) );
       System.out.println("Division: 4/3. = " + (4/3.) );
       System.out.println("Division: 5./3 = " + (5./3) );

       // Expressions containing relational components ....

       int iB = 1; int iC = 2; 
       System.out.println("\nRelational expressions : iB = 1; iC = 2");
       System.out.println("Test: iB > iC  = " + (iB > iC) );
       System.out.println("Test: iC > iB  = " + (iC > iB) );
       System.out.println("Test: iC == iB = " + (iC == iB) );
       System.out.println("Test: iC != iB = " + (iC != iB) );

       // Exercise math constants .... for details, see pg. 526 of A/C.

       System.out.println("\nExercise math constants ..");
       System.out.println("Math: e  = " + Math.E );
       System.out.println("Math: pi = " + Math.PI );

       // Exercise math functions .... for details, see pg. 526 of A/C.

       System.out.println("\nExercise math functions ..");
       System.out.println("Math: sin(pi) = " + Math.sin( Math.PI ) );
       System.out.println("Math: cos(pi) = " + Math.cos( Math.PI ) );
       System.out.println("Math: square root 2 = " + Math.sqrt( 2 ) );
       System.out.println("Math:     2^3 = " + Math.pow( 2, 3 ) );
       System.out.println("Math:  e^(pi) = " + Math.pow( Math.E, Math.PI ) );

       // Exercise max and min function .....

       System.out.println("\nExercise max and min functions ..");
       System.out.println("Math: min(2,3) = " + Math.min( 2, 3 ) );
       System.out.println("Math: max(2,3) = " + Math.max( 2, 3 ) );
       System.out.println("Math: max( max(-4, 3), -3) = " +
                                                Math.max( Math.max( -4, 3 ), -3 ) );

       // Exercise abs, round, and floor functions .... 

       System.out.println("\nExercise round and floor functions ..");
       System.out.println("Math:     abs (pi) = " + Math.abs (  Math.PI ) );
       System.out.println("Math:    abs (-pi) = " + Math.abs ( -Math.PI ) );
       System.out.println("Math: round   (pi) = " + Math.round ( Math.PI ) );
       System.out.println("Math: round (5*pi) = " + Math.round ( 5*Math.PI ) );
       System.out.println("Math: floor   (pi) = " + Math.floor (  Math.PI ) );
       System.out.println("Math: floor  (-pi) = " + Math.floor ( -Math.PI ) );

   }
}