Yes—if the user asks for five lines, a loop should count 1, 2, 3, 4, 5. What to do for each line remains a mystery.
Here is the skeletal program, with the usual blue blanks. The program so far ignores what is to be done for each printed line of stars. It just assumes that somthing can be done, and focuses on getting the number of lines right.
import java.io.*; // class starBlock { public static void main (String[] args ) throws IOException { int numRows; // the number of Rows int numStars; // the number of stars per row int row; // current row number BufferedReader userin = new BufferedReader (new InputStreamReader(System.in)); String inputData; // collect input data from user System.out.println( "How many Rows?" ); inputData = userin.readLine(); numRows = Integer.parseInt( inputData ); System.out.println( "How many Stars per Row?" ); inputData = userin.readLine(); numStars = Integer.parseInt( inputData ); __________________ while ( __________________ ) { (more statements soon will go here ) __________________ } } }
Some of the information collected from the user will not be used yet. First concentrate on looping once for each line to be printed.