public class Methods4 { public static void main(String[] args) { System.out.println("int: "+myRand(1,10)); System.out.println("bit: "+myRand()); System.out.println("char: "+myRand('a','z')); } // Return random int, low <= high: public static int myRand(int low, int high) { if (low > high) { System.out.println("myRand Failure!"); System.exit(0); } return (int) (Math.random()*(high-low+1)) + (int) low; } // Return random bit: public static boolean myRand() { return 1 == (int) (Math.random()*2); } // Return random letter, c1 <= c2: public static char myRand(char c1, char c2) { return (char) myRand((int)c1,(int)c2); } }