Calendar Project c++
-
Upload
aditya-sharma -
Category
Documents
-
view
759 -
download
86
Transcript of Calendar Project c++
TERM PAPER
OBJECT ORIENTED PROGRAMMING SYSTEM
CSE202
TOPIC- CALENDAR
SUBMITTED TO : SUBMITTED BY:
SHAISHAV SIR ANURAG KUMAR
ROLL NO- 07
SEC- E1801
REG NO- 10809115
CONTENTS
1. INTRODUCTION
2. SOURCE CODE
a. A1.cpp – It displays the welcome screen. It lets the user enter the date.
b. A2.cpp - It checks for the wrong date if entered.
c. A3.cpp - It checks for the leap year and assigns the correct number of days
in the month to the variable.
d. A4.cpp - It checks for the wrong of February.
e. A5.cpp - It displays the calendar of the month entered by the user.
f. A6.cpp - It displays the day on the date entered by the user.
g. A7.cpp - It links all the programs mentioned above.
h. Calmain.cpp - It is the main program of the project
3. DESCRIPTION OF THE PROGRAMS
4. SCREENSHOTS
a. ENTERING DATE
b. LOADING SCREEN
c. LOADING
d. PRINTING CALENDER AND DAY
e. ERROR SCREEN INVALID DATE
5. HARDWARE & SOFTWARE REQUIREMENTS
INTRODUCTION
The project of CSE202 is calendar. I have to prepare a software in which we
have to print the month calendar and day of the specific date. This software is
programmed in Turbo c ++. The software is basically designed to print calendar.
This software is very useful for all the sectors. More over this type of software
is very much used today in cell phones and computers etc.
I have used linking of programs in my project. I have made 6 programs for
different operations and then I have linked them all in my 7th program. And after
that I have linked the 7th program to my main program. So all together 7
programs have been linked with the main program. I have declared the variables
globally and then they have been used in all the class.
SOURCE CODE
A1.cpp
#include<iostream.h>
#include<conio.h>
#include<dos.h>
long int n=0,i,z1=0,z2=0,z3=0,r1=0,r2=0,r3=0,d=0,m=0,y=0,nod1=0,j;
long int s=0,p=0,s1=0,p1=0,p2=0,leap=0,lp=0,x=0,days=0,lpg=0,ch=0,st=0;
char w;
class a1
{
public:
virtual void getd();
};
void a1::getd()
{
clrscr();
textcolor(2);
gotoxy(20,4);
cout<<"************ CALENDER ************\n";
gotoxy(16,6);
cout<<"FIND OUT THE DAY ON THE DATE ENTERED BY YOU\n";
gotoxy(16,8);
cout<<"ENTER THE DATE IN THIS FORMAT (15 10 2005)\n";
delay(1000);
gotoxy(25,12);
textcolor(2);
cout<<"ENTER THE DATE :";
cin>>d>>m>>y;
clrscr();
textcolor(4);
gotoxy(5,10);
w=219;
textcolor(4);
cout<<"LOADING CALENDER OF THE MONTH ";
for(j=1;j<40;j++)
{
delay(100);
cout<<w;
}
textcolor(2);
gotoxy(5,13);
cout<<"LOADING DAY OF THE DATE ";
for(j=1;j<40;j++)
{
delay(100);
textcolor(4);
cout<<w;
}
clrscr();
textcolor(2);
gotoxy(30,13);
cout<<"PLEASE WAIT ";
for(j=1;j<10;j++)
{
delay(500);
textcolor(4);
cout<<".";
}
delay(2000);
clrscr();
}
A2.cpp
#include<iostream.h>
#include<process.h>
#include"a1.cpp"
class a2:public a1
{
public:
void getd();
};
void a2::getd()
{
int j;
if(y<1900)
{
gotoxy(15,18);
cout<<"THE DATE ENTERED IS OUT OF COMPUTER'S MEMORY";
gotoxy(10,20);
textcolor(4);
w=222;
cout<<"EXITING ";
for(j=1;j<50;j++)
{
delay(200);
cout<<w;
}
exit(0);
}
if(m>12||m<1)
{
gotoxy(15,18);
cout<<"INVALID DATE !! PLEASE ENTER A VALID DATE";
gotoxy(10,20);
textcolor(4);
w=222;
cout<<"EXITING ";
for(j=1;j<50;j++)
{
delay(200);
cout<<w;
}
exit(0);
}
if(d<1)
{
gotoxy(15,18);
cout<<"INVALID DATE !! PLEASE ENTER A VALID DATE";
gotoxy(10,20);
textcolor(4);
w=222;
cout<<"EXITING ";
for(j=1;j<50;j++)
{
delay(200);
cout<<w;
}
exit(0);
}
if(((m==1)||(m==3)||(m==5)||(m==7)||(m==8)||(m==10)||(m==12))&&(d>31))
{
gotoxy(15,18);
cout<<"INVALID DATE !! PLEASE ENTER A VALID DATE";
gotoxy(10,20);
textcolor(4);
w=222;
cout<<"EXITING ";
for(j=1;j<50;j++)
{
delay(200);
cout<<w;
}
exit(0);
}
if(((m==4)||(m==6)||(m==9)||(m==11))&&(d>30))
{
gotoxy(15,18);
cout<<"INVALID DATE !! PLEASE ENTER A VALID DATE";
gotoxy(10,20);
textcolor(4);
w=222;
cout<<"EXITING ";
for(j=1;j<50;j++)
{
delay(200);
cout<<w;
}
exit(0);
}
}
A3.cpp
#include<iostream.h>
#include<process.h>
class a3:public a1
{
public:
void getd();
};
void a3::getd()
{
if((y%400==0)||((y%100!=0)&&(y%4==0)))
{
lpg=29;
}
else
{
lpg=28;
}
if((m==2)&&(d>lpg))
{
gotoxy(15,18);
cout<<"INVALID DATE !! PLEASE ENTER A VALID DATE";
gotoxy(10,20);
textcolor(2);
char w;
w=222;
textcolor(2);
cout<<"EXITING ";
textcolor(4);
for(j=1;j<50;j++)
{
delay(200);
cout<<w;
}
exit(0);
}
}
A4.cpp
#include<iostream.h>
#include<process.h>
class a4:public a1
{
public:
void getd();
};
void a4::getd()
{
x=y;
s=y-1900;
p=s*365;
for(i=1900;i<x;i++)
{
r1=i%4;
r2=i%400;
r3=i%100;
if((r2==0)||((r3!=0)&&(r1==0)))
{
leap=leap+1;
}
}
days=leap+p;
for(s1=0;s1<m;s1++)
{
if((s1==1)||(s1==3)||(s1==5)||(s1==7)||(s1==8)||(s1==10)||(s1==12))
{
p1=p1+31;
}
else if((s1==4)||(s1==6)||(s1==9)||(s1==11))
{
p2=p2+30;
}
else if(s1==2)
{
z1=y%4; z2=y%400; z3=y%100;
if((z2==0)||((z3!=0)&&(z1==0)))
lp=29;
else lp=28;
}
}
}
A5.cpp
#include<iostream.h>
#include<process.h>
class a5:public a1
{
public:
void getd();
};
void a5::getd()
{
nod1=p1+p2+lp+days+(d-1);
n=nod1%7;
st=p1+p2+lp+days;
ch=st%7;
gotoxy(32,5);
textcolor(9);
switch(m)
{
case 1: cout<<"JANUARY"; break;
case 2: cout<<"FEBRUARY"; break;
case 3: cout<<"MARCH"; break;
case 4: cout<<"APRIL"; break;
case 5: cout<<"MAY"; break;
case 6: cout<<"JUNE"; break;
case 7: cout<<"JULY"; break;
case 8: cout<<"AUGUST"; break;
case 9: cout<<"SEPTEMBER"; break;
case 10: cout<<"OCTOBER"; break;
case 11: cout<<"NOVEMBER"; break;
case 12: cout<<"DECEMBER"; break;
}
textcolor(9);
cout<<y;
cout<<"\n\n";
cout<<"\nSUNDAY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY ";
textcolor(15);
if(ch==6) cout<<"";
else if(ch==0) cout<<" ";
else if(ch==1) cout<<" ";
else if(ch==2) cout<<" ";
else if(ch==3) cout<<" ";
else if(ch==4) cout<<" ";
else if(ch==5) cout<<" ";
for(i=1;i<=31;i++)
{
cprintf(" %2d ",i);
if((i+ch-1)%7==0)
{
textcolor(15);
cout<<" ";
}
if(m==2&&i==lpg) break;
if(((m==4)||(m==6)||(m==9)||(m==11))&&i==30) break;
}
}
A6.cpp
#include<iostream.h>
#include<conio.h>
class a6:public a1
{
public:
void getd();
};
void a6::getd()
{
gotoxy(20,20);
textcolor(2);
cout<<"THE DAY ON "<<d<<"/"<<m<<"/"<<y<<" IS: ";
textcolor(11+128);
switch(n)
{
case 0: cout<<"MONDAY"; break;
case 1: cout<<"TUESDAY"; break;
case 2: cout<<"WEDNESDAY"; break;
case 3: cout<<"THURSDAY"; break;
case 4: cout<<"FRIDAY"; break;
case 5: cout<<"SATURDAY"; break;
case 6: cout<<"SUNDAY";break;
default: cout<<"ERROR";
}
}
A7.cpp
#include<iostream.h>
#include"a2.cpp"
#include"a3.cpp"
#include"a4.cpp"
#include"a5.cpp"
#include"a6.cpp"
Calmain.cpp
#include"a7.cpp"
#include<iostream.h>
#include<conio.h>
//main function
void main()
{
a1 *ap, ao1;
a2 ao2;
a3 ao3;
a4 ao4;
a5 ao5;
a6 ao6;
ap=&ao1;
ap->getd();
ap=&ao2;
ap->getd();
ap=&ao4;
ap->getd();
ap=&ao3;
ap->getd();
ap=&ao5;
ap->getd();
ap=&ao6;
ap->getd();
getch();
}
DESCRIPTION OF THE CLASSES CREATED IN THE PROGRAM
Programs DescriptionA1.cpp It displays the welcome screen. It lets the
user enter the date.A2.cpp It checks for the wrong date if entered.A3.cpp It checks for the leap year and assigns the
correct number of days in the month to the variable.
A4.cpp It checks for the wrong of February.A5.cpp It displays the calendar of the month entered
by the user.A6.cpp It displays the day on the date entered by the
user.A7.cpp It links all the classes mentioned above.Calmain.cpp It is the main program of the project.
SCREENSHOTS
1. ENTERING DATE
2. LOADING SCREEN
3. LOADING
4. PRINTING CALENDER AND DAY
5. ERROR SCREEN INVALID DATE
HARDWARE & SOFTWARE REQUIREMENTS
1. Borland C++ or Turbo C++ complier required.
2. Minimum PC-XT or PC-AT-286 or PS/2.
3. Operating system:-DOS (Disk Operating System) OrAny Microsoft Windows Operating System or Linux/Unix Operating SystemMinimum Version 2.0 for Turbo C++ (TC)OrMinimum Version 3.0 for Borland C++(BC) MS-Windows-95 which is optional.
4. RAM(Random Access Memory):-Minimum 640 kb (kilobytes)
5. Hard Disk:-Minimum 6MB Hard disk for permanent storage of C++ complier and its related files.
6. One Floppy Disk Drive (1.44 MB).
7. One CD-Drive for C++ complier installation.
8. 80 column monochrome or colour monitor.
9. Mouse (for Windows Based C++ compiler)
10. One keyboard for Program Editing.