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