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 12 System.out.print("Number of rows? "); 13 Scanner scanner = new Scanner(System.in); 14 int rows = scanner.nextInt(); 15 System.out.print("Number of column? "); 16 int columns = scanner.nextInt(); 17 drawRectangle(rows, columns); 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 29 private static void drawOneRow(int nrOfColumns) { 30 for (int i = 0; i < nrOfColumns; i++) { 31 System.out.print("*"); 32 } 33 System.out.println(); 34 } 35 } 36