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