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 8 import java.util.Scanner; 9 10 public class TextRectangles { 11 public static void main(String[] args) { 12 Scanner scanner = new Scanner(System.in); 13 System.out.println("Number of rows?"); 14 int row = scanner.nextInt(); 15 System.out.println("Number of columns?"); 16 int column = scanner.nextInt(); 17 drawRectangle(row, column); 18 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 System.out.println(); 27 } 28 } 29 30 private static void drawOneRow(int nrOfColumns) { 31 int i = 1; 32 while ( i <= nrOfColumns) { 33 i=i+1; 34 System.out.print("*"); 35 } 36 37 } 38 } 39