1 package npw; 2 3 import java.util.Scanner; 4 5 public class TextRectangles { 6 public static void main(String[] args) { 7 8 System.out.println("run:"); 9 int nrOfRows = Stars("number of Rows?"); 10 int nrOfColumns = Stars("number of columns? "); 11 drawRectangle(nrOfRows,nrOfColumns); 12 } 13 14 private static int Stars(String question) { 15 System.out.println(question); 16 Scanner scanner = new Scanner(System.in); 17 int stars = scanner.nextInt(); 18 return stars; 19 } 20 21 private static void drawRectangle(int nrOfRows, int nrOfColumns) { 22 int i = 1; 23 while (i <= nrOfRows){ 24 drawOneRow(nrOfColumns); 25 i = i + 1 ; 26 } 27 } 28 29 private static void drawOneRow(int nrOfColumns) { 30 int x = 1; 31 while (x <= nrOfColumns) { 32 System.out.print("*"); 33 x = x + 1 ; 34 } 35 System.out.println(); 36 } 37 } 38