1 /* 2 This set of code will: 3 (1) accept, from the standard input stream, 4 data corresponding to the number of rows and number of columns 5 in a rectangle made up of stars, and 6 (2) print, to the standard output stream, the rectangle of stars. 7 */ 8 package npw; 9 10 import java.util.Scanner; 11 12 public class TextRectangles { 13 public static void main(String[] args) { 14 15 Scanner lexi = new Scanner(System.in); 16 17 System.out.print("Number of Rows: "); 18 int nrOfRows = lexi.nextInt() ; 19 20 System.out.print("Number of Columns: "); 21 int nrOfColumns = lexi.nextInt(); 22 23 drawRectangle(nrOfRows, nrOfColumns); 24 25 } 26 27 private static void drawRectangle(int nrOfRows, int nrOfColumns) { 28 29 int i = 1; 30 while ( i <= nrOfRows) { 31 drawOneRow(nrOfColumns); 32 System.out.println("*"); 33 i=i+1; 34 } 35 } 36 37 private static void drawOneRow(int nrOfColumns) { 38 int i = 1; 39 while (i <= nrOfColumns - 1){ 40 System.out.print("*"); 41 i = i + 1 ; 42 } 43 } 44 } 45