/* * Program to draw rectangles of stars in the standard output stream. The * dimensions of the rectangle are read from the standard input stream. */ package npw; import java.util.Scanner; public class TextRectangles { public static void main(String[] args) { //input information Scanner scanner = new Scanner(System.in); System.out.print("number of rows? "); int rows = scanner.nextInt(); System.out.print("number of columns? "); int columns = scanner.nextInt(); drawRectangle(rows, columns); } private static void drawRectangle(int nrOfRows, int nrOfColumns) { int i = 1; while (i <= nrOfRows) { drawOneRow(nrOfColumns); i = i + 1; } } private static void drawOneRow(int nrOfColumns) { for (int i = 0; i < nrOfColumns; i = i + 1) { System.out.print("*"); } System.out.println(); } }