I have to write a program that will list each month of the year and the day of the week that the month begins on. The program will take as input the year and the day of the week that January 1st falls on in that year. Assume that a leapĀ· year is any year which is divisible by 4.
Samples of input and output for correctly running programs:
1st Example
EXAMPLE INPUT:
Please enter the year: 2013
Please enter the day of the week for the first day of the year
(0-Sunday, 6-Saturday): 2
EXAMPLE OUTPUT:
January starts on a Tuesday
February starts on a Friday
March starts on a Friday
April starts on a Monday
May starts on a Wednesday
June starts on a Saturday
July starts on a Monday
August starts on a Thursday
September starts on a Sunday
October starts on a Tuesday
November starts on a Friday
December starts on a Sunday
2nd Example
EXAMPLE INPUT:
Please enter the year: 2012
Please enter the day of the week for the first day of the year
(0-Sunday, 6-Saturday): 0
EXAMPLE OUTPUT:
January starts on a Sunday
February starts on a Wednesday
March starts on a Thursday
April starts on a Sunday
May starts on a Tuesday
June starts on a Friday
July starts on a Sunday
August starts on a Wednesday
September starts on a Saturday
October starts on a Monday
November starts on a Thursday
December starts on a Saturday
Give each day of the year a day number from 1-365 or 1-366 for leap years. Using modular arithmetic the day can be determined if you know the starting day.
Arrays of days per month and day names are very useful here. You only need one if, to determine leap years. Probably about 20 lines max.