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