Hi all, I'm trying to set this up so that you can put a number in, positive or negative, and it will add or subtract form the array index so the correct day will show up (like subtracting past sunday goes to saturday and beyond, adding past saturday goes to sunday and beyond.
I thought I would try for loops so I could add the number one at a time and be able to control the overlap. However, I'm having trouble getting it to read out properly.
1 2 3 4
cout << endl << " Add days to " << dayNameArray[day.dayChoice] << "? (Enter a number to add, or a negative number to subtract): " << endl;
cin >> day.plusDays;
cout << endl << " Now the day is " << day.addDays(day.plusDays) << ". ";
//I've also tried dayNameArray[day.addDays(day.plusDays)] here and it still returns it as 0
That's the statement I'm trying to pull from. Here is the method.
Thanks roshi, that works but I have to make it work with a class. I have several other calls before this one, but this is the only one that doesn't work. I don't totally understand what's going on in the middle with all the cur_days's
Suppose dayChoice is 1 and plusDays is 17=7+7+3=7*2+3. We want the resulting dayChoice to be 4. We don't care about how many sevens we have in 17, because when you add seven days you have the same day as the one you had in the beginning. We only care about that 3, and the way to get it is 17%7. So, what we do is: