/home/ssingh6/NetBeansProjects/CS1/src/npw/TextRectangles.java
 1 /*
 2  * To change this license header, choose License Headers in Project Properties.
 3  * To change this template file, choose Tools | Templates
 4  * and open the template in the editor.
 5  */
 6 package npw;
 7 
 8 import java.util.Scanner;
 9 
10 /**
11  *
12  * @author ssingh6
13  */
14 public class TextRectangles {
15 
16     /**
17      * @param args the command line arguments
18      */
19     public static void main(String[] args) {
20        
21          System.out.print("number of rows? ");
22          Scanner scanner = new Scanner(System.in);
23          int nrOfRows = scanner.nextInt();
24          System.out.print("number of columns? ");
25          int nrOfColumns = scanner.nextInt();
26          drawRectangle(nrOfRows,nrOfColumns);
27      }
28  
29      private static void drawRectangle(int nrOfRows, int nrOfColumns) {
30          int i = 1;
31          while (i <= nrOfRows){
32             drawOneRow(nrOfColumns);
33              i = i + 1 ;
34          }
35     }
36  
37     private static void drawOneRow(int nrOfColumns) {
38          int j = 1;
39         while (j <= nrOfColumns) {
40             System.out.print("*");
41              j = j + 1 ;
42         }
43         System.out.println();
44      }
45     
46  }
47 
48