Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 28th, 2012, 11:46 AM
mariamh37 mariamh37 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Location: USA
Posts: 1 mariamh37 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 36 sec
Reputation Power: 0
Help Writing my first program!

Hello! This is one of the second programs I have been assigned to do, but as a beginner I am a little bit lost on where to start and how to go about creating this program.

The program I have to write is to:
Finding the day of the week corresponding to a specific date.
-It has to read a date
-Compute the corresponding day of the week N using the formula given below
-Output the result (with the day of the week as a word not a number)

I have to use Zeller's congruence equation
h = ( q + (13*(m+1))/5 + K + K/4 + J/4 + 5*J)

where:
- J is the number of the century [i.e. the year / 100],
- K the year within the century [i.e. the year % 100],
- m the month,
- q the day of the month,

Note that in this formula:
- the month indices are: March: 3, April: 4,...but with January being 13 and February being 14.
- January and February are counted as part of the previous year

h is a representation of the date as number of days since a starting time. It can then be converted into a day of the week using: N = h%7
i.e. the remainder of the division of h by 7. N is the day of the week, with 0 being Saturday, 1 being Sunday,...

As a beginner I am kind of lost. Could anyone give me any tips on how to go about writing this program? Thank You!

Reply With Quote
  #2  
Old November 28th, 2012, 11:58 AM
rrashkin's Avatar
rrashkin rrashkin is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2012
Location: 39N 104.28W
Posts: 90 rrashkin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 13 h 41 m 29 sec
Reputation Power: 2
I think you start with a date being supplied. This will probably be a user input (?) and we'll need to make some assumption about the format. For now, let's say that the date comes in American-style: mm/dd/yyyy.

First split the user input string on "/" and assign month,day,year variables to the elements (after converting the strings to numbers):
Code:
mnth,dy,yr=map(int,datestring.split('/'))

Now you want to get the variables in your designated algorithm from those 3 variables:
Code:
J=yr/100
K=yr%100
if mnth<3: mnth+=12
m=mnth
q=dy


What more do you need?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Help Writing my first program!

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap