When I execute this code the output is "140" which is "28*5" but it should be "150" which is "28+31+30+31+30" it should calculate the days between 2 months "feb" and "july"... So it means that the for loop isn't working correctly or what ? and why is that ! can you help me here ?? PS: I tried to change the j++ in the loop to j+1 but Android Studio Says"that's not a statement"
int[] pair = {1,3,5,7,8,10,12};
int[] impair = {4,6,9,11};
int x=0;
int j;
int year=2015;
int mm=2;
int month=7;
String msg="";
if (month>mm) {
for (j = mm; j<month; j++){
if (Arrays.asList(impair).contains(j)){
x = 31 + x;
}else if(Arrays.asList(pair).contains(j)){
x = 30 + x;
}else{
if (year%4==0) {
x= 29 + x;
}else{
x= 28 + x;
}
}
}
System.output.println(x);
}