Billing Period
May 18, 2018
I’m not sure of the origin of today’s exercise, but given the contrived nature of the calculation, I suspect it’s a programming exercise for beginning programming students:
Our merchants receive “weekly” invoices, following these rules:
- Each Saturday marks the beginning of a new billing period.
- Each 1st of a month marks the begining of a new billing period.
- Within a year, billing periods are numbered consecutively, starting with billing period 1 on January 1st.
Thus, a billing period can be referenced by a year and period number.
Your task is to write a program that calculates the billing period for a given date. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.