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