/home/evankemp/NetBeansProjects/CS1/src/npw/TextRectangles.java
 1 /*
 2  * Program to draw rectangles of stars in the standard output strean. The
 3  * dimensions of teh rectangle are read from the standard input stream.
 4  */
 5 package npw;
 6 
 7 import java.util.Scanner;
 8 
 9 /**
10  *
11  * @author evankemp
12  */
13 public class TextRectangles {
14 
15     /**
16      * @param args the command line arguments
17      */
18     public static void main(String[] args) {
19         Scanner scanner = new Scanner(System.in);
20         System.out.println("number of rows? ");
21         int nrOfRows = scanner.nextInt();
22         System.out.println("number of columns? ");
23         int nrOfColumns = scanner.nextInt();
24         drawRectangle(nrOfRows, nrOfColumns);
25     }
26 
27     private static void drawRectangle(int nrOfRows, int nrOfColumns) {
28         int i = 1;
29         while (i <= nrOfRows) {
30             drawOneRow(nrOfColumns);
31             i = i+1;
32         }
33     }
34 
35     private static void drawOneRow(int nrOfColumns) {
36         int i = 1;
37         while (i<=nrOfColumns) {
38             System.out.print("*");
39             i = i+1;
40         } 
41       System.out.println();
42         
43               
44     }
45     
46 }
47