You are on page 1of 21

“Counting the

Dates”
(Calend

Name: romy garg


Board roll number:
“project submitted towards aissce-2018”
Vikas Bharati Public School
Rohini, New Delhi

Certificate
This is to certify Romy Garg, student of class 12th , has

completed the Computer Science Project

during the academic year 2017-2018

for partial fulfillment of credit of Computer Science

Practical Evaluation of

CBSE -2017 and submitted satisfactory report on

project entitled “COUNTING THE DATES” under

my supervision.

Acknowledgement
I have taken efforts in this project. However, it would not
have been possible without the kind support and help of
many individuals and organizations. I would like to
extend my sincere thanks to all of them.

I am highly indebted to Mrs. Anni Kumar for her


guidance and constant supervision as well as for
providing necessary information regarding the project &
also for their support in completing the project.
I would like to express my gratitude towards my parents
for their kind co-operation and encouragement which
help me in completion of this project.
My thanks and appreciations also go to my colleague in
developing the project and people who have willingly
helped me out with their abilities.

ROMY GARG
Preface
The focus of this project is to create a
calender program using data file handling.
The user can access the different options
once they input the right CAPTCHA code.
The user can get the option to view the
calender of the month he wishes, the day of
the date he enters, to add and show his
important events using a class. It also
comprises the various functions as per the
requirement of the project.
Header files used
Sno Header files
1 iostream.h Manages input and
output function to
the console.
2 conio.h Handles function like
clrscr(), getch(), etc.
3 stdio.h Handles function like
gets().
4 string.h Handles function like
strcmp().
5 fstream.h Manages reading
and writing
functions to
associated data file.
6 math.h Handles floor().
User-defined
functions used
Sno Name Use
1 void It displays a
dis_calender() monthly
calendar.
2 void It add or shows
add_show(int) record in a
binary file
”EVENT.DAT”.
3 void dis_day() It tells the user
day of a
particular date
given by user.
SOURCE
CODE
#include<iostream.h>

#include<conio.h>

#include<fstream.h>

#include<math.h>

#include<string.h>

#include<stdlib.h>

#include<stdio.h>

class day

{ int date;

int month;

int year;

char event[10];

public:

void getdata()

{ cout<<endl<<endl<<"\t"<<" Enter date: ";

cin>>date;

cout<<endl<<"\t"<<" Enter month: ";

cin>>month;

cout<<endl<<"\t"<< "Enter year: ";

cin>>year;
cout<<endl<<"\t"<<" Enter event: ";

gets(event);

void showdata()

{ cout<<endl<<endl<<"\t"<<" Day: "<<date;

cout<<endl<<"\t"<<" Month: "<<month;

cout<<endl<<"\t"<<" Year: "<<year;

cout<<endl<<"\t"<<" Event: "<<event;

};

void dis_day();

void add(int);

void dis_calender();

void main()

{ char
serial[]={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o
','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P
','Q','R','S','T','U','V','W','X','Y','Z'};

char flag[6],temp[6];

int choice;

char ans='y';

clrscr();
randomize();

for(int i=0;i<=4;i++)

flag[i]=serial[random(62)];

flag[i]='\0';

gotoxy(25,10);

cout<<" The captcha code is: ";

for(i=0;i<=4;i++)

cout<<flag[i];

cout<<endl<<endl;

cout<<"\t\t\t";

cout<<" Enter the captcha code: ";

cin.getline(temp,6);

if(strcmp(flag,temp)==0)

{ cout<<"\t\t\t"<<" Captcha code matched!!";

getch();

else

{ cout<<"\t\t\t"<<" Captcha code not matched!!";

getch();

goto exit;

getch();
//code to check the user by captcha code verification

clrscr();

cout<<endl<<endl;

cout<<endl<<endl<<"\t\t\t"<<" ***MENU*** ";

cout<<endl<<"\t\t\t"<<" 1. Display calender";

cout<<endl<<"\t\t\t"<<" 2. Know the day of the particular date";

cout<<endl<<"\t\t\t"<<" 3. Add a event";

cout<<endl<<"\t\t\t"<<" 4. View the event";

cout<<endl<<"\t\t\t"<<" Please enter your choice;";

cin>>choice;

clrscr();

do

{ switch(choice)

{ case 1 : dis_calender();

break;

case 2 : dis_day();

break;

case 3 : add(1);

break;

case 4 : add(0);

break;

default : goto exit;


}//end of switch

cout<<endl<<"\t\t\t"<<" Do you want to continue?(y/n): ";

cin>>ans;

clrscr();

}while(ans=='y'||ans=='Y');//end of loop

clrscr();

getch();

exit:

void add(int n)

{ day ob;

char ans='y';

fstream f;

f.open("EVENT.DAT",ios::in|ios::out|ios::app|ios::binary);

if(n==1)

{ do

{ ob.getdata();

f.write((char*)&ob,sizeof(ob));

cout<<endl<<"\t\t\t"<<" Do you want to add more event:";

cin>>ans;

}while(ans=='y'||ans=='Y');
}

else

{ f.seekg(0);

while(f.read((char*)&ob,sizeof(ob)))

ob.showdata();

f.close();

}//end of function

void dis_day()

{ int k,m,d,c,y,f,ans,n;

cout<<endl<<"\t\t\t"<<" Enter date: ";

cin>>k;

cout<<endl<<"\t\t\t"<<" Enter month: ";

cin>>m;

if(m>2)

n=m-2;

else

n=m+10;

cout<<endl<<"\t\t\t"<<" Enter year: ";

cin>>d;

if(m==11||m==12)
d=d-1;

cout<<endl<<"\t\t\t"<<" Enter century: ";

cin>>c;

cout<<endl;

f=k+floor(((13*n)-1)/5)+floor(d/4)+d+floor(c/4)-(2*c);

ans=f%7;

cout<<endl<<"\t\t\t";

switch(ans)

{ case 0 : cout<<"***SUNDAY***";

break;

case 1 : cout<<"***MONDAY***";

break;

case 2 : cout<<"***TUESDAY***";

break;

case 3 : cout<<"***WEDNESDAY***";

break;

case 4 : cout<<"***THURSDAY***";

break;

case 5 : cout<<"***FRIDAY***";

break;

case 6 : cout<<"***SATURDAY***";

break;
default : cout<<"***An unexpected error occured***";

getch();

void dis_calender()

{ int f,d,m,c,ans,num_day,i,n;

cout<<" Month: ";

cin>>m;

if(m>2)

n=m-2;

else

n=m+10;

cout<<" Year: ";

cin>>d;

cout<<" Century: ";

cin>>c;

f=1+floor(((13*n)-1)/5)+floor(d/4)+d+floor(c/4)+(c*2);

ans=f%7;

cout<<"s\tm\tt\tw\tt\tf\ts"<<endl;

for(i=0;i<ans;i++)

cout<<"\t";
{ if((m==1)||(m==3)||(m==5)||(m==7)||(m==8)||(m==10)||(m==12))

num_day=31;

else if(m==2)

{ if(d%4==0)

num_day=29;

else

num_day=28;

else

num_day=30;

for(i=1;i<=num_day;i++)

if((i+ans)%7==0)

cout<<i<<endl;

else

cout<<i<<"\t";

}
OUTPUTS
Bibliography
 Computer Science with C++ by Preeti
Arora and Pinky Gupta
 cplusplus.com
 Math Forum: Ask Dr Math FAQ:
Calendar and Days of the week

Software Used

 TURBO C++

You might also like