Conditions

Report a typo

The program below should calculate the sum of all odd and even numbers from 1 to 1000. Complete the following program to achieve the expected result.

Fill in the gaps with the relevant elements
public class Main {
    public static void main(String[] args) {
        int oddSum = 0, evenSum = 0;
        int i = 0;

        while () {
            i++;
            if () {
                evenSum += i;
            }
            if () {
                oddSum += i;
            }
        }
        System.out.println("Sum of odd numbers: " + oddSum);
        System.out.println("Sum of even numbers: " + evenSum);
    }
}
i % 2 == 0i % 2 != 500i / 2 != 500i % 2 == 1i / 2 != 0

Create a free account to access the full topic