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    import shapes.SRectangle;
8    
9    import java.util.Scanner;
10   public class TextRectangles {
11       public static void main(String [] args){
12           System.out.println("number of rows?");
13           Scanner scanner= new Scanner(System.in);
14           int row= scanner.nextInt();
15   
16           System.out.println("number of columns?");
17           int column= scanner.nextInt();
18           drawRectangle(row, column);
19       }
20       private static void drawRectangle(int nrOfRows, int nrOfColumns) {
21           int i = 1;
22           while ( i <= nrOfRows) {
23               drawOneRow(nrOfColumns);
24               i=i+1;
25   
26           }
27       }
28   
29   
30       private static void drawOneRow(int nrOfColumns) {
31          for ( int i= 0; i < nrOfColumns; i++) {
32   
33               System.out.print("*");
34           }
35           System.out.println();
36       }
37   
38   
39   }
40   
41