0% found this document useful (0 votes)
49 views15 pages

CSE TP By: Sudhanshu

This document contains a term paper on creating a calendar program in C++ using object oriented programming. It includes an introduction to calendars, different types of calendar systems, descriptions of calendars with one or two levels of cycles, the content and structure of the program, and functions to check for leap years, get month names and numbers of days, print the calendar layout, and more. The program is designed to output a calendar for any given year when the user inputs the year and starting day of the week for January 1st.

Uploaded by

Sudhanshu Mishra
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views15 pages

CSE TP By: Sudhanshu

This document contains a term paper on creating a calendar program in C++ using object oriented programming. It includes an introduction to calendars, different types of calendar systems, descriptions of calendars with one or two levels of cycles, the content and structure of the program, and functions to check for leap years, get month names and numbers of days, print the calendar layout, and more. The program is designed to output a calendar for any given year when the user inputs the year and starting day of the week for January 1st.

Uploaded by

Sudhanshu Mishra
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

TERM PAPER

Object Oriented Programming with C++

DOA: 09/01/2010
DOS: 11/08/2010

Topic: Calendar

Submitted To: Submitted By:


Miss Pallavi Jassi Mam Sudhanshu Shekhar Mishra
Deptt. Of CSE Class: B.Tech(ECE)
Section:Rm6901
Roll No: RM6901B50
ACKNOWLEDGEMENT

I would first like to thank my Computer teacher Pallavi mam,


for her tremendous support and contribution from time to time
giving me several information and data related to this term
paper .
I am also thankful to my friends, who have helped me for
making my term paper. Last but not least I would like to
thankful to my parents, who has helped me to encourage and
giving moral support for making this term paper.

Sudhanshu Mishra
B. Tech (ECE 3rd Sem.)
Content:

• Introduction
• Calendar Systems
• Calendars with two levels of cycles
• Program on Calendar
• Reference
Introduction:

A calendar is a system of organizing days for social, religious, commercial, or administrative


purposes. This is done by giving names to periods of time, typically days, weeks, months, and
years. The name given to each day is known as a date. Periods in a calendar (such as years
and months) are usually, though not necessarily, synchronized with the cycle of the sun or the
moon. Many civilizations and societies have devised a calendar, usually derived from other
calendars on which they model their systems, suited to their particular needs.

A calendar is also a physical device (often paper). This is the most common usage of the
word. Other similar types of calendars can include computerized systems, which can be set to
remind the user of upcoming events and appointments.

A calendar can also mean a list of planned events, such as a court calendar.

The English word calendar is derived from the Latin word kalendae, which was the Latin
name of the first day of every month.

Calendar systems

A full calendar system has a different calendar date for every day. Thus the week cycle is by
itself not a full calendar system; neither is a system to name the days within a year without a
system for identifying the years.

The simplest calendar system just counts time periods from a reference date. This applies for
the Julian day. Virtually the only possible variation is using a different reference date, in
particular one less distant in the past to make the numbers smaller. Computations in these
systems are just a matter of addition and subtraction.

Other calendars have one (or multiple) larger units of time.

Calendars that contain one level of cycles:

• week and weekday – this system (without year, the week number keeps on increasing)
is not very common
• year and ordinal date within the year, e.g. the ISO 8601 ordinal date system

Calendars with two levels of cycles:

• year, month, and day – most systems, including the Gregorian calendar (and its very
similar predecessor, the Julian calendar), the Islamic calendar, and the Hebrew
calendar
• year, week, and weekday – e.g. the ISO week date

Cycles can be synchronized with periodic phenomena:

• A lunar calendar is synchronized to the motion of the Moon (lunar phases); an


example is the Islamic calendar.
• A solar calendar is based on perceived seasonal changes synchronized to the apparent
motion of the Sun; an example is the Persian calendar.
• A "luni-solar calendar" is based on a combination of both solar and lunar reckonings;
an example is the traditional calendar of China and the Hindu Calendar in India.
• There are some calendars that appear to be synchronized to the motion of Venus, such
as some of the ancient Egyptian calendars; synchronization to Venus appears to occur
primarily in civilizations near the Equator.
• The week cycle is an example of one that is not synchronized to any external
phenomenon (although it may have been derived from lunar phases, beginning anew
every month).

Very commonly a calendar includes more than one type of cycle, or has both cyclic and
acyclic elements. A lunisolar calendar is synchronized both to the motion of the moon and to
the apparent motion of the sun; an example is the Hebrew calendar.

Many calendars incorporate simpler calendars as elements. For example, the rules of the
Hebrew calendar depend on the seven-day week cycle (a very simple calendar), so the week
is one of the cycles of the Hebrew calendar. It is also common to operate two calendars
simultaneously, usually providing unrelated cycles, and the result may also be considered a
more complex calendar. For example, the Gregorian calendar has no inherent dependence on
the seven-day week, but in Western society the two are used together, and calendar tools
indicate both the Gregorian date and the day of week.

The week cycle is shared by various calendar systems (although the significance of special
days such as Friday, Saturday, and Sunday varies). Systems of leap days usually do not affect
the week cycle. The week cycle was not even interrupted when 10, 11, 12, or 13 dates were
skipped when the Julian calendar was replaced by the Gregorian calendar by various
countries.

Program on Calander

#include <iostream.h>

#include<conio.h>

#include <iomanip.h>

bool isLeapYear(int year); // check for leapyears

void printCal(int year, int start); // print calendar

void monthNums(int count, int& monthDays, int& spacerDays); //get how many days are
in last and current months

void monthNames(int count); // get month names

void dayNames(); //print day header names

void spacer(int start, int& colCount, int count, int& prevSpacer); /* makes months line up

correctly, if jan ends on monday, feb will start on tuesday */


void wrapper(int dayCount, int monthDays); // initiates line returns

bool question(int answer);

int answer;

int prevSpacer;

int year;

int start;

int monthDays;

int spacerDays;

int dayCount = 1;

int colCount = 0;

int halt; // used to stop the damn program so i can copy the output

int main()

question(answer);

printCal(year, start); // print calender

cin >> halt; // stop program so copy output

void question(int answer)

cout << "What year do you want a calendar for? " << endl;

cin >> year;


cout << "What day of the week does january 1 fall on?" << endl << "(Enter 0 for
sunday, 1 for monday, etc.)" << endl;

cin >> start;

if(start > 6)

cout << "that's too much man";

return false;

void printCal(int year, int start) // print calender

int count;

for (count = 1; count <= 12; count++){

monthNames(count); // print the current month name

dayNames(); // print the day identifiers

monthNums(count, monthDays, spacerDays); // get the number of days in the current


and last month

spacer(start, colCount, count, prevSpacer); // print spaces to line up days correctly.

wrapper(dayCount, monthDays); // initiate line returns on saturday

void wrapper(int dayCount, int monthDays) // initiate line returns

{
while (dayCount <= monthDays) /// while the day count is less than the number of days
in the month

if (colCount == 7) // if column count equals 7 (saturday) print a line return

cout << endl;

colCount = 0; // reset column count

cout << setw(3); // set width to 3

cout << dayCount; // print a day number

colCount++;

dayCount++;

colCount = 0;

cout << endl << endl; // space the months a bit more

bool isLeapYear(int year) // check for leap year

if (year % 400 == 0){ // if year/400 has no remainders - true

return true;

if (year % 100 == 0){// if year/100 has no remainders - false

return false;

}
if (year % 4 == 0){// if year/4 has no remainders - true

return true;

return false; // else false

void monthNums(int count, int& monthDays, int& spacerDays) // previous and current
days in each month

switch (count)

case 1:

monthDays = 31; // current month days

break;

case 2:

if(isLeapYear(year)) // check for leap year in feb

monthDays = 29;

if(!isLeapYear(year))

monthDays = 28;

spacerDays = 31; // previous month days

break;

case 3:
monthDays = 31;

if(isLeapYear(year)) //previous month days and leap year

spacerDays = 29;

if(!isLeapYear(year))

spacerDays = 28;

break;

case 4:

monthDays = 30;

spacerDays = 31;

break;

case 5:

monthDays = 31;

spacerDays = 30;

break;

case 6:

monthDays = 30;

spacerDays = 31;

break;

case 7:

monthDays = 31;

spacerDays = 30;

break;
case 8:

monthDays = 31;

spacerDays = 31;

break;

case 9:

monthDays = 30;

spacerDays = 31;

break;

case 10:

monthDays = 31;

spacerDays = 30;

break;

case 11:

monthDays = 30;

spacerDays = 31;

break;

case 12:

monthDays = 31;

spacerDays = 30;

break;

}
void monthNames(int count) // print month names

switch (count)

case 1:

cout << " January" << endl;

break;

case 2:

cout << " February" << endl;

break;

case 3:

cout << " March" << endl;

break;

case 4:

cout << " April" << endl;

break;

case 5:

cout << " May" << endl;

break;

case 6:
cout << " June" << endl;

break;

case 7:

cout << " July" << endl;

break;

case 8:

cout << " August" << endl;

break;

case 9:

cout << " September" << endl;

break;

case 10:

cout << " October" << endl;

break;

case 11:

cout << " November" << endl;

break;

case 12:

cout << " December" << endl;

break;

}
}

void dayNames() // print day ident

cout << " S M T W T F S" << endl;

void spacer(int start, int& colCount, int count, int& prevSpacer) // print spaces

if (count == 1) // used for the 1st month

int loopCount;

for (loopCount = 0; loopCount < start; loopCount++){

cout << " "; // print space

prevSpacer++; // keep track of spaces for next month

colCount =+ start;

else if (count != 1) //used for all other months

int otherSpacer;

int loopCount;

int monthCount = count;


monthNums(monthCount, monthDays, spacerDays);

/* add previous number of spaces with previous number of days in month

then devide by seven, use the remainder for the

spaces in the current month */

otherSpacer = (prevSpacer + spacerDays) % 7;

prevSpacer = 0; // reset spacer

for (loopCount = 0; loopCount < otherSpacer; loopCount++){

cout << " "; // print space

prevSpacer++; // keep track of spaces for next month

colCount =+ otherSpacer;

getch();

Reference:

http://en.wikipedia.org/wiki/Calendar

Object oriented programming with C++

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy