I have a problem with the following java exercise, I'm starting with the language:
Make a program that calculates and shows the sum of the first N even numbers and the product of the first N odd numbers simultaneously, where N is a number that is entered by keyboard.
How could this exercise be done?
I got here, but when I give it I get the results of the multiplications in 0
int contador = 0;
int contador1 = 0;
int i = 0;
int j = 1;
for (i=0; i <= num; i++) {
if (i % 2 == 0) {
contador +=i;
System.out.println(contador);
}
} System.out.println("\n");
for (j=1; j <= num; j++) {
if (j % 2 !=0) {
contador1 *=j;
System.out.println((double)contador1);
}
}