TextRectangles.java
1    package npw;
2    
3    import interpreters.Interpreter1;
4    
5    import javax.swing.*;
6    
7    public class TextRectangles {
8    
9        public static void main(String[] args) {
10   
11           int rows = Integer.parseInt(JOptionPane.showInputDialog(null, "Number of Rows"));
12           int columns = Integer.parseInt(JOptionPane.showInputDialog(null, "Number of Columns" ));
13   
14           drawRectangle(rows, columns);
15   
16       }
17   
18       private static void drawRectangle(int nrOfRows, int nrOfColumns) {
19   
20           int i = 1;
21           while (i <= nrOfRows) {
22               drawOneRow(nrOfColumns);
23               i=i+1;
24               System.out.println("");
25           }
26   
27       }
28   
29       private static void drawOneRow(int nrOfColumns) {
30   
31           for (int i = 1; i <= nrOfColumns; i = i + 1) {
32               System.out.print("*");
33           }
34   
35       }
36   
37   }
38