/home/akc/NetBeansProjects/CS1/src/npw/TextRectangles.java
 1 /*
 2  * A program to accept data corresponding to the number of rows and columns in a
 3  * rectangle made up of stars, and print it.
 4  */
 5 package npw;
 6 
 7 import java.util.Scanner;
 8 
 9 /**
10  *
11  * @author akc
12  */
13 public class TextRectangles {
14 
15     /**
16      * @param args the command line arguments
17      */
18     public static void main(String[] args) {
19         //CREATING A SCANNER
20         Scanner scanner = new Scanner(System.in);
21         //ASKING THE USER FOR INPUT
22         System.out.print("Number of rows? ");
23         int nrOfRows = scanner.nextInt();
24         System.out.print("Number of columns? ");
25         int nrOfColumns = scanner.nextInt();
26         drawRectangles(nrOfRows,nrOfColumns);
27     }
28     
29     private static void drawRectangles(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