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