![]() |
How to skip a number in java
Hello to all.
I have this code for my class and I what I am trying to do is decrement the number 39 by two so that odd numbers show, until I get to zero using the "for loop" The issue is that I am suppose to exclude the numbers 33, and 3 when it prints the numbers out. I can't figure that part out, and I can't find it anywhere in the chapter that I had to read on this. Can someone please help me understand how i should do this? This is the code I have so far, but I took out the extra for statements for clarity, beacuse I thought they would help me but they don't. If I am suppose to use if statements, I don't know how to do this excluding 3 and 33. :
|
Re: How to skip a number in java
Hey everyone, I figured it out about 5 minutes after I asked. Sorry, but thanks to those who would have helped anyway. :) Here is the solution that I found worked.
:
|
Re: How to skip a number in java
There's a simpler way to do it, using an
if statement. Here's the pseudocode::
loop i from 39 to 0 step 2:By the way, to enclose Java code, you should do this: Quote:
|
Re: How to skip a number in java
did you mean "every time the digit 3 is attained, ignore it"? or just the values 33 & 3? If its any digit, 3, then you might want to use some kind of toString() then get rid of the 3 then toInt()
|
| All times are GMT -5. The time now is 5:55 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC