Skipping An Iteration in Loops

Hey guys -

I'm trying to write a program for class that calculates number of unoccupied and occupied rooms in a hotel, how many floors in the hotel etc..

The problem I'm having is getting the program to skip the 13th floor, since most hotels don't have one. I tried putting in an 'if' statement telling it to continue if the value of 'floors == 13', but that didn't work. Any ideas?

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell

I tried putting in an 'if' statement telling it to continue if the value of 'floors == 13', but that didn't work.

Was it an infinite loop? Perhaps you didn't increment the loop variable.

dwk

Seek and ye shall find. quaere et invenies.

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell

>> I tried putting in an 'if' statement telling it to continue if the value of 'floors == 13', but that didn't work. Any ideas?

That sounds like the correct solution. Post the code with that in it and tell us how it didn't work. dwks is probably right, you have to increment the loop variable before you continue, since in the example the increment is done in the loop control, but in your code the increment is done in the part of the code that would be skipped by the continue.

Since I don't know where you inserted the if statement, I can't be sure what your particular problem was, but if you insert it at the beginning and increment the counter, you shouldn't have any problems. Also, you have 2 counter variables that do the same thing. If you move the incremented counter to the end of the loop, you can remove count2, making your code just a little bit cleaner and easier to read.