/home/ffrigin/NetBeansProjects/CS1/src/npw/TextRectangles.java |
1
2
3
4
5 package npw;
6
7 import java.util.Scanner;
8
9
10
11 @author
12
13 public class TextRectangles {
14
15
16 @param args
17
18 public static void main(String[] args) {
19 Scanner scanner = new Scanner(System.in);
20 System.out.println("Please enter the number of rows: ");
21 int nrOfRows = scanner.nextInt();
22 System.out.println("Please enter the number of columns: ");
23 int nrOfColumns = scanner.nextInt();
24 drawRectangle(nrOfRows, nrOfColumns);
25
26 }
27
28 private static void drawRectangle(int nrOfRows, int nrOfColumns) {
29 int i = 1;
30 while (i <= nrOfRows) {
31 drawOneRow(nrOfColumns);
32 i = i + 1;
33 }
34 }
35
36 private static void drawOneRow(int nrOfColumns) {
37 int f = 1;
38 while (f <= nrOfColumns) {
39 System.out.print("*");
40 f = f + 1;
41 }
42 System.out.println();
43
44 }
45
46 }
47