Question: Write a function to determine the day of the week a person was born given his or her birthday. The following steps should be used
Write a function to determine the day of the week a person was born given his or her birthday. The following steps should be used to find the day of the week corresponding to any date from through the present.
In the following explanation, the following terms will be helpful. Assuming I type in my birthday as :
The month is
The day of the month is
The year is
Find the number of years since and put it into a variable called yy Simply subtract from the year to get this.
Divide the number of years since by Put the quotient in a variable called total. For example, if the person was born in divide by and store in total.
Also add the number of years since to total.
Add the day of the month to total.
Using the function monthoffset described in the following, find the "month offset" and add it to total.
If the year is a leap year and if the month you are working with is either January or February, then subtract from the total. You can use the function isleap provided to determine if the year is a leap year.
Find the remainder when total is divided by Pass this remainder to the function weekdayname you wrote to determine the day of the week the person was born.
Finally, build up a single String value containing the whole date day of week, month, day, year You'll need to use the function monthname you wrote to show the month name rather than its number.
Return that String value.
Whew. Here's some code to get you started.
Welcome to MCISs fantastic birthometer!
All you have to do is enter your birthday, and it will tell you
the day of the week on which you were born.
Some automatic tests....
Wednesday, December
Friday, February
Sunday, February
Tuesday, July
Wednesday, January
Friday, October
Now it's your turn! What's your birthday?
Birthday mm dd yyyy:
You were born on Thursday, November
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
