I am working on this example and I do not know what I am doing.
public square Nestlove {public static zero main (string [] args) {int userNum = 0; Int i = 0; Int j = 0; While (j & lt; = userNum) {System.out.println (j); ++ j; For (i = j; i & lt; = userNum; ++ i) {System.out.print (""); }} Return; }}
The result is below. As you can see, my result is backward and I am not sure what I am doing wrong. I have tried to change the variable around and I am not getting any help. Any help would be greatly appreciated
Expected Output: 0 1 2 3 Your Output: 0 1 2 3 < / Code> thanks
you increase the number of spaces after the return You are using userNum
for error and increment j ++
you can also remove the return statement.
Correct code:
public square Nestlove {public static zero main (string [] args) {int userNum = 3; Int i = 0; Int j = 0; While (j & lt; = userNum) {System.out.println (j); (I = 0; i & lt; = j; ++ i) {System.out.print (""); } ++ j; }}}
No comments:
Post a Comment