// methods
// some typical patterns I've seen...helps show what's possible:

public class methods {
    public static void main(String[] args) {
	
	printRand();
	myPrint1(1);
	printSometimes(-2);
	printSometimes(2);
	myPrint1(twiceValue(2) + 3);
	myPrint1(myRandom(10,1));
	
	int x = 100, y = 200;
	myPrint1(myAdd(x,y));
	myPrint1(x); myPrint1(y);

	/* sample output:
	   
	   A random number: 0.0474547160725467
	   MyPrint1: 1
	   A ha! x is ok: 2
	   MyPrint1: 7
	   MyPrint1: 0
	   MyPrint1: 600
	   MyPrint1: 100
	   MyPrint1: 200
	*/

    }

    // void, no formal param
    public static void printRand() {
	System.out.println("A random number: "+Math.random());
    }

    // void, 1 formal param (many more parameters are possible)
    // performs action on an input
    public static void myPrint1(int x) {
	System.out.println("MyPrint1: "+x);
    }
    
    
    // void, return early if necessary
    public static void printSometimes(int x) {
	if (x < 0)
	    return;
	System.out.println("A ha! x is ok: "+x);
    }
    
    // simple return of a value
    public static int twiceValue(int x) {
	return 2*x;
    }
	
    // void, return a value
    public static int myRandom(int low, int high) {
	int tmp;
	if (high >= low )
	    tmp = (int)( (Math.random()*(high-low+1)) + low);
	else
	    tmp = 0;
	return tmp;
    }
    
    // many input
    public static int myAdd(int x, int y) {
	x = x*2; y = y*2;
	return x+y;
    }
    
}
