import java.util.Scanner;

public class DrawRectangle
{
  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args)
  {
    int width, height, i;

    System.out.println("This program will output a rectangle.");
    width = getPosNumber("How wide do you want it? ");
    height = getPosNumber("How tall? ");

    for (i=0; i < height; i++)
    {
      outputLine('*', width);
      System.out.println();
    }
  }

  // This function outputs the prompt to the console, reads input
  // from the console, and converts it to a number,
  // which the function returns.  If the number is not positive,
  // the user is told to enter a new number until a positive number is entered.
  static int getPosNumber(String prompt)
  {
    int val;
    do
    {
      System.out.print(prompt);
      val = sc.nextInt();
      if (val <= 0) System.out.println("You must enter a positive integer");
    } while(val <= 0);
    return val;
  }

  // output size number of the char s.
  static void outputLine(char s, int size)
  {
    for (int i=0; i < size; i++)
      System.out.print(s);
  }
}


syntax highlighted by Code2HTML, v. 0.9