Professional Documents
Culture Documents
Dates”
(Calend
Certificate
This is to certify Romy Garg, student of class 12th , has
Practical Evaluation of
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.
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()
cin>>date;
cin>>month;
cin>>year;
cout<<endl<<"\t"<<" Enter event: ";
gets(event);
void showdata()
};
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);
for(i=0;i<=4;i++)
cout<<flag[i];
cout<<endl<<endl;
cout<<"\t\t\t";
cin.getline(temp,6);
if(strcmp(flag,temp)==0)
getch();
else
getch();
goto exit;
getch();
//code to check the user by captcha code verification
clrscr();
cout<<endl<<endl;
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;
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));
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;
cin>>k;
cin>>m;
if(m>2)
n=m-2;
else
n=m+10;
cin>>d;
if(m==11||m==12)
d=d-1;
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;
cin>>m;
if(m>2)
n=m-2;
else
n=m+10;
cin>>d;
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++