Friday, August 28, 2009

CALENDER

DESCRIPTION:-
The primary practical use of a calendar is to identify days: to be informed about and/or to agree on a future event and to record an event that has happened. Days may be significant for civil, religious or social reasons. For example, a calendar provides a way to determine which days are religious or civil holidays, which days mark the beginning and end of business accounting periods, and which days have legal significance, such as the day taxes are due or a contract expires. Also a calendar may, by identifying a day, provide other useful information about the day such as its season.
Calendars are also used as part of a complete timekeeping system: date and time of day together specify a moment in time. In the modern world, written calendars are no longer an essential part of such systems, as the advent of accurate clocks has made it possible to record time independently of astronomical events.



ANALYSIS:-

1) For the year 1752, the days from 3 to 13 are neglected in month 9 and directly print days this case.
2) Divide the input year by 400, 4. If the remainder is zero then the year entered is a leap year. In this case, add a day to the month 2. If it is divided by 100 it shouldn’t be zero.
* Determines if a year is a leap year.
* Input parameters:
* Year (must be >0)
* Returns:
* 1 if the year is a leap year, 0 otherwise.
*


3) To calculate days in a month
Calculates the number of days in a month.
* Input parameters:
* Year (must be >0)
* Month (1 to 12)
* Returns:
* The number of days in the month (28 to 31)





4) Week day for a date
* Calculates the weekday for a given date.
* Input parameters:
* Year (must be >0)
* Month (1..12)
* Day (1..31)
* Returns:
* 0 for Sunday, 1 for Monday, 2 for Tuesday, etc…




5) Calculates the week number
* Input parameters:
* Year (must be >0)
* Month (1 to 12)
* Day
* Output parameters:
* Address of week number (1 to 53)
* Address of corresponding year
*




ALGORITHM:-

1. Set base week starts from Saturday i.e., for 1 January 0001
2. Check the input, if case it is 1752 treat as a special case and a 11 day correction is made in month 9.
3. Ensure that the year entered should be greater than zero.
4. Number of months in a year should be 12.
5. For the months 1, 3, 5,7,8,10,12, number of days in each month should be 31.
6. And for the months 4, 6,9,11 numbers of days in each month is to be 30.
7. And for the month 2, the days are to be 28 and if the year entered is a leap year, add a day.




FLOWCHARTS:-




1. For the setting the base value:

start


Set week January 0001
as Saturday.


stop


2) For calculating the leap year


start

year divides false stop
400 or 4 completely

true

stop


3. Number of months in a year

start


Calculate the number of months
in a year that is, to
print in according order.


stop

No comments:

Post a Comment