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 System.out.print("number of rows? "); 13 Scanner sc = new Scanner(System.in); 14 int nrOfRows = sc.nextInt(); 15 System.out.print("number of columns?"); 16 Scanner scanner = new Scanner(System.in); 17 int nrOfColumns = scanner.nextInt(); 18 drawRectangle(nrOfRows, nrOfColumns); 19 } 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 i = 0; 33 while ( i < nrOfColumns) { 34 System.out.print("*"); 35 i = i + 1; 36 } 37 } 38 } 39 40