This site requires JavaScript, please enable it in your browser!
Greenfoot back
LimeLite
LimeLite wrote ...

2020/6/20

I am trying to document numbers increasing by increments of ten, any tips?

LimeLite LimeLite

2020/6/20

#
Hi, I am currently trying to find a way to code an if statement where instead of the int being a certain value, I want the if statement to trigger every time the int goes up by ten. Any tips would be helpful.
danpost danpost

2020/6/20

#
LimeLite wrote...
I want the if statement to trigger every time the int goes up by ten.
if (count%10 == 0) {
LimeLite LimeLite

2020/6/20

#
Thanks for the help man! I forgot that modulus existed
danpost danpost

2020/6/20

#
LimeLite wrote...
Thanks for the help man! I forgot that modulus existed
Even if it didn't, you could do this:
if (count-(count/10)*10 == 0) {
(keeping in mind that count is an int) This, (count/10)*10, "shakes" off the remainder; so, subtracting it from the original value leaves the remainder.
You need to login to post a reply.