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