It is my first post in this forum, I am starting to program, and this question has arisen in an exercise. I have to find the sum of the next 20 numbers to a number entered by keyboard, and the sum of the next 20 even numbers. This is my code:
if(numero%2==0){
boolean par=true;
}else{
boolean par=false;
}
if(par==true){
for(int i=numero, j=numero+40;i<=j;i+2){ //Este i+2 es lo que tengo mal
total_par=total_par+i;
}
}else{
for(int i=numero+1,j=numero+40;i<=j;i+2){ //Aquí también
total_par=total_par+i;
}
}
Thanks