package RelationsAndBooleans;

/**
 * Test.java
 *
 *
 * Created: Thu Mar 22 16:09:04 2001
 *
 * @author Stuart C. Shapiro
 */

public class Test {
    public Test (){}

    public static boolean isDivisibleBy(int x, int y){
	return y!=0 && x%y==0;
    }

    public static boolean isInOrder(int x, int y, int z){
	return x <= y && y <= z;
    }

    public static int absoluteValue(int x){
	return (x<0 ? -x : x);
    }

    public static int sign(int x){
	return
	    x>0 ? 1
	    : x<0 ? -1 : 0;
    }

    public static void main (String[] args) {
	System.out.println("Is 12 divisible by 4?:  " + isDivisibleBy(12,4));
	System.out.println("Is 12 divisible by 5?:  " + isDivisibleBy(12,5));
	System.out.println("Is 12 divisible by -6?:  " + isDivisibleBy(12,-6));
	System.out.println("Is 12 divisible by -5?:  " + isDivisibleBy(12,-5));
	System.out.println("Is 12 divisible by 0?:  " + isDivisibleBy(12,0));
	
	System.out.println();

	System.out.println("Is 5, 7, 12 in order?:  " + isInOrder(5, 7, 12));
	System.out.println("Is 5, 12, 7 in order?:  " + isInOrder(5, 12, 7));
	System.out.println("Is 7, 5, 12 in order?:  " + isInOrder(7, 5, 12));

	System.out.println();

	System.out.println("The absolute value of 4 is:  "
			   + absoluteValue(4));
	System.out.println("The absolute value of -4 is:  "
			   + absoluteValue(-4));
	System.out.println("The absolute value of 0 is:  "
			   + absoluteValue(0));

	System.out.println();
	System.out.println("The sign of -5 is:  " + sign(-5));
	System.out.println("The sign of 0 is:  " + sign(0));
	System.out.println("The sign of 5 is:  " + sign(5));
    } // end of main ()
    
}// Test
