Author | Message |
---|---|
smahbub2
Posts: 12
|
Posted 14:22 May 17, 2015 |
Hey everyone, I hate to be asking help for the third time on the same lab, but I'm seriously clueless here. The goal is to make a table with varying x and y rows/columns for a table. And the column numbers show up fine, but only on one row, not the varying rows. It's probably a simple solution that I'm just completely oblivious to, but can anyone point out whats wrong and give me advice regarding my code. It would be a lifesaver, scratch that, a grade-saver which is much more important. Any help is appreciated. The x and y variable are given, I just didn't want to make this post longer than it' should. Here's the code: var colNum = y; |
fumjum
Posts: 27
|
Posted 14:33 May 17, 2015 |
I'm not in your class and so I don't know what the assignment is but it looks like the second while loop is an endless loop since the variable currCol never changes inside the loop so it can never become false once the loop starts. You increase currROW in it but test whether currCol is less than rowNum. Either change it to test whether currROW is less than rowNum or increase currCol in the loop depending on what you're trying to do. If I'm wrong I apologize. I have a different professor than you. Paul Last edited by fumjum at
14:35 May 17, 2015.
|
cesar714
Posts: 30
|
Posted 15:10 May 17, 2015 |
ok, so according to your code what you are doing is creating two separate tables. what you want is a single table. In order to do this you need to do a nested loop. That is a loop within a loop. so it should look as follows. while(rows){ while(columns){} } |
chondee
Posts: 9
|
Posted 15:26 May 17, 2015 |
Pretty much what Cesar said. You have asked this in another identical topic less than 24 hours ago, don't start new ones if it isn't necessary. |