[Solved] My Java code is not running [closed]


As others stated before, value of remainder is set only once. However, you check it a hundred times expecting it to tell you something else every time. I’d suggest putting it inside a loop, so you get a “fresh” value for every number.

public class Even {

public static void main(String args[]) {

    int number = 1;
    int remainder;

    while(number <= 100) {
        number++;
        remainder = number % 2;
        if(remainder == 0) {
            System.out.println(number);
        }
    }

}

}

solved My Java code is not running [closed]