1 2 /* 3 * Program to draw rectangles of stars in the standard output stream. The 4 * dimensions of the rectangle are read from the standard input stream. 5 */ 6 7 package npw; 8 9 import java.util.Scanner; 10 11 public class TextRectangles { 12 public static void main(String[] args) { 13 System.out.println("Enter number of rows"); 14 Scanner one = new Scanner(System.in); 15 int rows = one.nextInt(); 16 System.out.println("Enter number of columns"); 17 Scanner two = new Scanner(System.in); 18 int columns = two.nextInt(); 19 drawRectangle(rows,columns); 20 } 21 22 private static void drawRectangle(int nrOfRows, int nrOfColumns) { 23 int i = 1; 24 while (i <= nrOfRows) { 25 drawOneRow(nrOfColumns); 26 i = i + 1; 27 } 28 } 29 30 private static void drawOneRow(int nrOfColumns) { 31 for ( int i = 1; i <= nrOfColumns; i = i + 1){ 32 System.out.print("*"); 33 34 } 35 System.out.println(); 36 } 37 }