public int getWorkingDays(int startIndex,int days2go){
int x=days2go;//10 days after
int n=startIndex;//starting week index, from 2nd day of week
int corrector=((7-n)+1); // by this way we are starting to count from
monday
int weeks=((int)((x-corrector)/7));//number of weeks
int full5day=weeks*5;// number of working days in weeks
int firstcorrected=corrector-2;// first remained days, we subtract to
correct index
int remainder=(int)Math.IEEEremainder(x-corrector,7);
//less then 7 using mod 7
// last remained days from full weeks
if(remainder<0){
remainder=x-corrector;
}
int remaineddays;
if(remainder>5){
remaineddays=7-(int)Math.IEEEremainder(remainder,6);
//exclude saturday with mod 6
}else{
remaineddays=remainder;
}
int result=full5day+firstcorrected+remaineddays+1;// ups +1 for correct
your result
return result;
}