
/** 
 Program: 	EssentialOperators
 Purpose: 	simple demonstration of Java operators.
 @author 	john@december.com 
 @version	1.05; 21 Nov 95 
 Note:          converted to 1.00 beta
 Output:        
		UNARY OPERATORS
		-42
		-3.14159
		42
		43
		BINARY OPERATORS
		142
		38.8584
		314.159
		14
		14
		1.0472
		0
		RELATIONAL OPERATORS
		false
		false
		true
		true
		true
		false
		BOOLEAN OPERATORS
		false
		false
		true
		true
		false
		true
		false
		Mr. Kyle is cool.
		Mr. Kyle, the answer is 42
 */

class EssentialOperators {

   public static void main (String args[]) {

      int     myInteger   = 42;
      float   myReal      = 3.14159f;
      String  someName    = "Mr. Kyle";
      boolean myTruth     = true;  
      int     myArray[]   = {1856, 1984};

      System.out.println("UNARY OPERATORS");
      System.out.println(-myInteger);  // negate an integer
      System.out.println(-myReal);     // negate a real number
      System.out.println(myInteger++); // display the number then add 1 to it
      System.out.println(myInteger--); // display the number then subtract 1
      
      System.out.println("BINARY OPERATORS");
      System.out.println(myInteger + 100);    // addition
      System.out.println(myInteger - myReal); // subtraction
      System.out.println(100 * myReal);       // multiplication
      System.out.println(myInteger/3.0f);      // division with real
      System.out.println(myInteger/3);        // division without remainder
      System.out.println(myReal/3);           // real division

      System.out.println(myInteger%3);        // modulo arithmetic shows
                                              // remainder after dividing by 3

      System.out.println("RELATIONAL OPERATORS");
      System.out.println(myInteger < 32);     // less than
      System.out.println(myInteger == 32);    // equal to
      System.out.println(myInteger != 32);    // not equal to
      System.out.println(myInteger > 32);     // greater than
      System.out.println(myInteger >= 32);    // greater than or equal to
      System.out.println(myInteger <= 32);    // less than or equal to

      System.out.println("BOOLEAN OPERATORS");
      System.out.println(!myTruth);           // negation of true or false 
      System.out.println(!myTruth & myTruth); // and 
      System.out.println(!myTruth | myTruth); // or
      System.out.println(!myTruth ^ myTruth); // exclusive or (XOR)
      System.out.println(myTruth ^ myTruth);  // exclusive or (XOR)
      System.out.println(myTruth == true);    // compare equals
      System.out.println(myTruth != true);    // compare not equals

      System.out.println(someName + " is cool.");  // add to a string
      System.out.println(someName + ", the answer is " + myInteger);  
                                               // add number to strings

   }
}
