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 1901 through the present.
In the following explanation, the following terms will be helpful. Assuming I type in my birthday as "6 10 1981":
The month is 6.
The day of the month is 10.
The year is 1981.
Find the number of years since 1900, and put it into a variable called yy. Simply subtract 1900 from the year to get this.
Divide the number of years since 1900 by 4. Put the quotient in a variable called total. For example, if the person was born in 1983, divide 83 by 4 and store 20 in total.
Also add the number of years since 1900 to total.
Add the day of the month to total.
Using the function month_offset() 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 1 from the total. You can use the function is_leap() provided to determine if the year is a leap year.
Find the remainder when total is divided by 7. Pass this remainder to the function weekday_name() 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 month_name() 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 MCIS5103's fantastic birth-o-meter!
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....
12 10 2003 => Wednesday, December 10, 2003
2 13 1976 => Friday, February 13, 1976
2 13 1977 => Sunday, February 13, 1977
7 2 1974 => Tuesday, July 2, 1974
1 15 2003 => Wednesday, January 15, 2003
10 13 2000 => Friday, October 13, 2000
Now it's your turn! What's your birthday?
Birthday (mm dd yyyy): 11 11 2010
You were born on Thursday, November 11, 2010!
The function that gives you the "month offset" should be following the table below
Month |
Month offset |
1 |
1 |
2 |
4 |
3 |
4 |
4 |
0 |
5 |
2 |
6 |
5 |
7 |
0 |
8 |
3 |
9 |
6 |
10 |
1 |
11 |
4 |
12 |
6 |
anything else |
-1 |
We need at least 10 more requests to produce the answer.
0 / 10 have requested this problem solution
The more requests, the faster the answer.
Write a function to determine the day of the week a person was born given his...
PYTHON I need some basic python homework help! Write a program that prompts the user to enter a date (day, month, and year). Your program will print out the day of the week for that date. You do not need to validate the input. That means you can assume: the year will be entered as a four-digit number in the range 1900 through 2100 inclusive. the month will be one of the strings "January", "February", . . ., "December". the...
Write a C# program that prints a calendar for a given year. Call this program calendar. The program prompts the user for two inputs: 1) The year for which you are generating the calendar. 2) The day of the week that January first is on, you will use the following notation to set the day of the week: 0 Sunday 1 Monday 2 Tuesday 3 Wednesday 4 Thursday 5 Friday 6 Saturday Your program should...
Write a C# program that prints a calendar for a given year. Call this program calendar. This program needs to use Switch Case in order to call the methods and format to print each month. The program prompts the user for two inputs: 1) The year for which you are generating the calendar. 2) The day of the week that January first is on, you will use the following notation to set the day of the week: ...
In Java You are to write a program that determines the day of the week for New Year's Day in the year 3000. To do this, you must create your own date class (MyDate) and use the following interface and main program: /** Interface for Date objects to be used by the Year3000 driver program. @author Jon Sorenson */ public interface DateInterface { /** @return the day of the month (1-31) */ public int getDay(); /** @return the day of...
Write a script in matlab that prompts the user to input the day, month, and year; determine the day of the year (the number of days including the current day). Be sure to take leap year into account. Use a for loop Test your code on the following dates: February 28, 2015 April 9, 1976 October 12, 1887 Create a script that performs the same function as repmat. The only built-in commands you may use are input, size, and disp.
C++ question Suppose that today is April 1st of the year 2019. By entering your birthday, print what is a day of the week you were born and how many days passed since you were born. Remember that January 1st of the year 2019 is Tuesday See the example below Read 1/1/2019 - Tue 90 Read 4/1/2019 - Mon 0 Read 4/1/2018 - Sun 365 Read 4/1/2017 -> Sat 730 Read 4/1/2016 Fri 1095 Read 4/1/2015-> Wed 1461 Bye... Wikipedia...
in python Worth 5 points (Science: day of the week) Zeller's congruence is an algorithm developed by Christian Zeller to calculate the day of the week. The formula is h= (q + 26(m+1)//10 + k + k//4 +j//4 +5j) % 7 where - h is the day of the week (0: Saturday, 1: Sunday, 2: Monday, 3: Tuesday, 4: Wednesday, 5: Thursday, 6: Friday). - is the day of the month. m is the month (3: March, 4: April, ...,...
USING PYTHON. (Science: day of the week) Zeller’s congruence is an algorithm developed by Christian Zeller to calculate the day of the week. The formula is h = (q + 26(m+1)//10 + k + k//4 +j//4 +5j) % 7 where - h is the day of the week (0: Saturday, 1: Sunday, 2: Monday, 3: Tuesday, 4: Wednesday, 5: Thursday, 6: Friday). - q is the day of the month. - m is the month (3: March, 4: April, ...,...
Write a program that does the following in Python Code: Write a new Class called Famous_Day_Born which is a subclass of Famous_Person. Add a method to calculate the day of the week the person was born and print out all of the corresponding information using the overridden print method. Use the following code below as a starting point. ////////////////////////////////////////////////////// from datetime import datetime class Famous_Person(object): def __init__(self, last, first, month,day, year): self.last = last self.first = first self.month = month...
Need help implementing this Java class (Science: day of the week) Zeller's congruence is an algorithm developed by Christian Zeller to calculate the day of the week. The formula is h = (q + (26 * (m + 1)) / 10 + k + k / 4 + j / 4 + 5 * j) % 7 where h is the day of the week (0: Saturday, 1: Sunday, 2: Monday, 3: Tuesday, 4: Wednesday, 5: Thursday, 6: Friday). q...