TextRectangles.java
1    package npw;
2    
3    
4    import java.util.Scanner;
5    
6        public class TextRectangles {
7            public static void main(String[] args) {
8                System.out.println("run:");
9    
10               System.out.print("number of rows? ");
11               Scanner scanner = new Scanner(System.in);
12               int nrrow = scanner.nextInt();
13   
14               System.out.print("number of columns? ");
15               Scanner scan = new Scanner(System.in);
16               int nrcol = scan.nextInt();
17   
18               drawRectangle(nrrow, nrcol);
19           }
20   
21   
22           private static void drawRectangle(int nrOfRows, int nrOfColumns) {
23               int i = 1;
24               while ( i <= nrOfRows) {
25                   drawOneRow(nrOfColumns);
26                   i=i+1;
27               }
28           }
29   
30           private static void drawOneRow(int nrOfColumns) {
31               int i = 1;
32               while ( i <= nrOfColumns) {
33                   System.out.print("*");
34                   i=i+1;
35               }
36               System.out.println();
37   
38   
39           }
40   
41   
42       }
43   
44