CS1 Standard Demo Page

The following text was written to the standard output stream when the TextRectangles.java program was executed from Netbeans.

/*
 * Program to make an grid of stars and asking the user to input numbers to 
 * construct the grid.
 */
package npw;

import java.util.Scanner;

/**
 *
 * @author ecuevas
 */
public class TextRectangles {

    /**
     * @param args the command line arguments
     */
    
    public static void main(String[] args) {
    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) {
        int i = 1;
        while (i <= nrOfColumns) {
            i = i +1;
            System.out.print("*");
        }
        
        System.out.println();
    }
    
  
}