/**
 *          IntegerExample; Example program to to demonstrate
 *          the basic aspects of integer arithmetic.
 */


public class IntegerExample {
    public static void main(String args[]) {


	int first = 230;             // Declare and set two integer
	int second = 56;

	int third = first + second;  // Arithmentic just like doubles 

	//            Integer division return an int

	int ratio = third/second;                
	System.out.println("Result  of " + third + " divided by " 
			   + second + " is " + ratio);

	//            Modulo is the remainder after division....
	
	int modulo = first%second;
	System.out.println("Result  of " + first + " modulo  " 
			   + second + " is " + modulo);

	
	//          Increment and decement operators are a convenient
	//          method to add/substract 1 from an integer.
	//          You will see this again in loops.
 
	System.out.println("Value of first is : " + first);

	first++;                       // Add one

	System.out.println("After increment is  : " + first);

	first--;                       // Substract one

	System.out.println("After decrement is  : " + first);



	//      The use on increment/decrement operators can be 
	//      in expressions. There are TWO types.
	//  
	

	second = ++first;              // Increment first, and assign
	                               // new value to second
	System.out.println("First is " + first + " Second is " + second);

	
	//                   and

	second = first++;             // Assign current value to second
	                              // THEN increment first.
	System.out.println("First is " + first + " Second is " + second);


	//        
	//        .... but can result in some ``interesting'' code that
	//        is far from readable..... work of the example below and see
	//        what you get, its NOT obvious!!!! (Writing this sort of code
	//        could seriously damage your sanity!!!).

	first = 4;
	int puzzel = --first+first+++ ++first; 
	System.out.println("First is set to " + first + 
			   " puzzel is set to " + puzzel);
    }
}
