Problem 12 - ECOR1606 Problem Solving and Computers Page 1...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
ECOR1606 – Problem Solving and Computers Page 1 of 3 Department of Systems and Computer Engineering Carleton University P ERPETUAL C ALENDAR Background information For the Gregorian calendar it is possible to determine the day of the week (i.e. Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday) given the year, month, and day. (Aside: International standards ISO 8601 specify dates as year, month, and day, which is the accepted Canadian standard CSA Z234.5). If it is possible to determine what day of the week a particular date falls on, the generation of calendars become very easy. The following algorithm, titled the Key Value Method, is detailed at: http://mathforum.org/dr.math/faq/faq.calendar.html Key Value Method 1. Define the variables year , month , day . 2. Define the variable century and set it to equal the century number (e.g. year = 2003, century = 20; year = 1826, century = 18). 3. Define the variable remYear and set it equal to the last two digits of the year (e.g. year = 2003, remYear = 3; year = 1826, remYear = 26). 4. Define the boolean variable leapYear and set it to true if it is a leap year. A leap year is every fourth year (i.e. year is divisible by four with no remainder), except that every hundredth year is not a leap year (i.e. remYear is 0; e.g. 1900, 2100) but every 400
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

Problem 12 - ECOR1606 Problem Solving and Computers Page 1...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online