<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">import java.util.Scanner;

/* Methods for generating random numbers and letters
 */
public class MyRandom {
  
  /* = a random integer in [lo..hi]
   */
  public static int randInt(int lo, int hi) {
    return (int) (Math.random()*(hi-lo+1)) + lo;
  }
  
  /* = a random type double number in [lo..hi)
   */
  public static double randDouble(double lo, double hi) {
    return Math.random()*(hi-lo)+lo;
  }
  
  /* Example method calls
   */
  public static void main(String[] args) {

    Scanner keyboard= new Scanner(System.in);
    System.out.println("Enter lower bound: ");
    int L= keyboard.nextInt();
    System.out.println("Enter upper bound: ");
    int R= keyboard.nextInt();

    int r= randInt(L, R);
    System.out.println("Random int in [" 
                     + L + ".." + R + "]:  " + r);
    
    double d= randDouble(L, R);
    System.out.println("Random number in [" 
                       + L + "," + R + "):  " + d);
  }
    
  /* = a random letter in [A..Z] if UL is 1,
   * in [a..z] if UL is 0, otherwise return '?'.
   */
  public static char randLetter(int UL) {
    int rank= randInt(1,26);
    char letter= '?';
    
    if (UL==1)
      letter= (char) ('A'+rank-1);
    else if (UL==0)
      letter= (char) ('a'+rank-1);
    
    return letter;
  }
  
}//class MyRandom</pre></body></html>