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.
While and do-while loops
Conditions
Report a typo
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);
}
}Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.