I need to implement a mechanism in Java, which alternates a statement each week, eg. in week one it sets a variable to 10, in week two it sets it to 15 and in week 3 it sets it to 10 again.
This should work for every year. I now tried archeiving this by getting the week number and checking if it is even.(date.getWeekNumber() % 2 == 0).
The problem here is that the year 2014 does have only 52 weeks, while the year 2015 and 2016 do have 53 weeks. This would lead to having 53 % 2 = 1 and on the following week 1 % 1 = 1, which in my case would set the wrong variables.
Does anyone have a clue how to improve this?