My current task is to draw a square and im nowhere near into it. Been working on the project now for about 4 hours and im just confused. Heres my code, atm i can't even get it to do what i want it to do.
public class Main { public static void main(String args[]) { System.out.print("#Number Of Stars: "); int sizeofsquare = 5; int line = 1; int down = 1; int across = 1; System.out.println(); while ( line <= sizeofsquare ){ System.out.print("*"); line = line + 1; } while ( down < sizeofsquare ){ down = down + 1; System.out.println(); while ( across <= sizeofsquare ){ System.out.print("*"); across = across + 1; } } } }
Basically im trying to draw a square out of stars after having the user read in how many stars will be along the y and x.
for example if i read in 5 the square would be:
*****
*****
*****
*****
*****
and would change depending on the number i entered, the max number of stars being 40 along the x/y axis.
So far ive managed to get *'s to constantly generate after reading a number and have no idea why they don't stop when the count gets to the number that has been entered.