TextRectangles.java
1    /* 
2     * Program to draw rectangles of stars in the standard output stream. The 
3     * dimensions of the rectangle are read from the standard input stream. 
4     */
5    
6    package npw;
7    
8    import java.util.Scanner;
9    
10   public class TextRectangles {
11       public static void main(String[] args) {
12           Scanner scanner = new Scanner(System.in);
13           System.out.print(" How many rows would you like? ");
14           int nor = scanner.nextInt();
15           System.out.print(" How many columns would you like? ");
16           int noc = scanner.nextInt();
17           drawRectangle(nor, noc);
18       }
19   
20       private static void drawRectangle(int nor, int noc) {
21           int i = 1;
22           while ( i <= nor) {
23               drawOneRow(noc);
24               i=i+1;
25               System.out.println("");
26           }
27       }
28   
29       private static void drawOneRow(int noc) {
30           int k = 1;
31           while (k <= noc){
32               System.out.print("*");
33               k++;
34           }
35       }
36   }