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 * (The painter function isn't used at all why is this in npw?) 5 */ 6 7 package npw; 8 9 import java.util.Scanner; 10 11 public class TextRectangles { 12 public static void main(String[] args) { 13 Scanner ping = new Scanner(System.in); 14 System.out.println("run:"); 15 System.out.print("number of rows? "); 16 int nrOfRows = ping.nextInt(); 17 System.out.print("number of columns? "); 18 int nOfColumns = ping.nextInt(); 19 drawRectangle(nrOfRows, nOfColumns); 20 } 21 22 private static void drawRectangle(int nrOfRows, int nrOfColumns) { 23 int i = 1; 24 while ( i <= nrOfRows) { 25 drawOneRow(nrOfColumns); 26 System.out.println(); 27 i=i+1; 28 } 29 } 30 31 private static void drawOneRow(int nrOfColumns) { 32 int w = 1; 33 while (w <= nrOfColumns) { 34 System.out.print("*"); 35 w = w + 1; 36 } 37 38 } 39 }