Sunteți pe pagina 1din 34

Calendar

Project by:
1. Atharva Kitkaru (1814033)
2. Nishavak Naik (1814040)
Problem Definition
The following code takes an input from the user for month and year respectively.
The calendar is displayed in standard format, Month and year at the top. The days
are displayed starting with Sunday as the first day of the week. The program
prompts user with options to continue or exit

If user wishes to continue, program gives option to look for consecutive months or
years, look for altogether a different month of a year, or find out day that falls on
that date.

If user enters invalid inputs, the program prompts the user to re-enter the options.
Input specifications
1. User enters month and year, which should be in integer format
2. Month number should range from 1 to 12
3. Year for algorithm to work should be in the range 1 to 9999
4. Negative inputs not allowed
5. User should enter Y or N so as to continue or exit the program
6. User should enter options, if the user wishes to continue, as specified.
Output specifications
1. Month and year of the required month is displayed at the top of the Calendar
2. Calendar is displayed in standard format with starting day being Sunday
3. Options for user to continue with the program or exit are displayed at the end
of the calendar
4. Whatever user selects from given options, accordingly program displays the
output on the new cleared screen
5. Public holidays are displayed after calendar (if any).
Special processing
1. If user enters negative, out of range, or float values, prompt user to re-enter
values
2. If user enters invalid options, prompt the user to re-enter the options.
Objectives
➔ To display the calendar of particular month of year
➔ To find the day of particular date
➔ To navigate through consecutive months and years
➔ To display fixed public holidays in the month
Algorithm
1. Start
2. Read variables month and year from the user.
3.Check if the given year is leap year or not.
4.If year is divisible by 4 and not by not by 100,it is a leap year , otherwise not
5. If year is divisible and by 4 and 100 and not by 400 , it is not a leap year.
6.Calculate the number of days for the given month
7. Determine the day on 1st of that month by using zellner's formula : day code=(year code +month code+1+century code-leap year
code)%7
where ,day code=0 to 6 , 0 standing for sunday , 1 for monday and so on (method of calculating other codes is displayed in the
program)
8.After calculating number of days of the month and day on 1st of the month , print the calendar , starting from sunday till saturday.
9.Display public holidays in the calendar.
10.If the user enters y or Y , continue , else if user enters n or N, goto step 17 or display invalid input and repeat the step
11.If the user enters 1 goto step 12, else if user enters 2 go to step 2, else if user enters 3 , perform step 7 and substitute date for 1 in
the formula ,else display invalid input
12. If the user enters w, repeat steps 3 to 9 and print the calendar for the same month in previous year.
13. If the user enters s, repeat steps 3 to 9 and print the calendar for the same month in succeeding year.
14. If the user enters a, repeat steps 3 to 9 and print the calendar for the previous month in same year.
15. If the user enters d, repeat steps 3 to 9 and print the calendar for the next month in same year.
16. Go to step 10
17.Stop
code
Output
First impression
If Yes
If option 1
If ‘w’ is pressed
If ‘s’ is pressed
If ‘a’ is pressed
If ‘d’ is pressed
If option 2 was selected
If option 3 was selected
Conclusion
Use of pointers, user defined functions, arrays, conditional loops, conditional
statements etc. have been used to make this calendar.

S-ar putea să vă placă și