if/else test if y is a multiple of z

This is a self-check exercise from my Java book.

Given that two ints "y" and "z", is already declared.

How do I test if y is a multiple of z?

Quote:

//e. y is a multiple of z.

if (z == ) {

System.out.println("Correct");

}

else {

System.out.println("False");

}

Re: if/else test if y is a multiple of z

Check your textbook and read what the % (modulo) operator does.

kind regards,

Jos

Re: if/else test if y is a multiple of z

Thanks, Edit: finally got it, and obviously it was more easy than I thougt y%z == 0.

Re: if/else test if y is a multiple of z

Yep, that's it, except if z == 0

kind regards,

Jos