1 /* 2 *This program creates rectangles made of rows of asterisks of which the size is determined by user input. 3 */ 4 5 package npw; 6 import java.util.Scanner; 7 8 public class TextRectangles { 9 public static void main(String[] args) { 10 int nrOfColumns; 11 int nrOfRows; 12 Scanner scanner = new Scanner(System.in); 13 System.out.println("Enter number number of rows"); 14 nrOfRows = scanner.nextInt(); 15 System.out.println("Enter number of Columns"); 16 nrOfColumns = scanner.nextInt(); 17 drawRectangle(nrOfRows, nrOfColumns); 18 19 20 21 } 22 23 private static void drawRectangle(int nrOfRows, int nrOfColumns) { 24 int i = 1; 25 while ( i <= nrOfRows) { 26 drawOneRow(nrOfColumns); 27 i=i+1; 28 } 29 30 } 31 32 private static void drawOneRow(int nrOfColumns) { 33 // TODO Auto-generated method stub 34 int i = 1; 35 while ( i <= nrOfColumns) { 36 System.out.print("*"); 37 i=i+1; 38 } 39 40 System.out.println(""); 41 } 42 }