Mini Project: Designing A Calendar With Reminders and Coloured Background

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 18

MINI PROJECT

DESIGNING A CALENDAR WITH REMINDERS AND


COLOURED BACKGROUND
OBJECTIVE:

To construct a c program to design a calendar with reminders and coloured


background.

DESCRIPTION:

 START
 We have used system(“color 5F”) command which is used to set the
default console foreground and background colour.
 Colour attributes are specified by TWO hex digits -- the first
corresponds to the background; the second the foreground. Each digit
can be any of the following values:

0 = Black 8 = Gray
1 = Blue 9 = Light Blue
2 = Green A = Light Green
3 = Aqua B = Light Aqua
4 = Red C = Light Red
5 = Purple D = Light Purple
6 = Yellow E = Light Yellow
7 = White F = Bright White

 Here 5 refers to the purple coloured background and F refers to the white
coloured foreground in this project.
 The COLOR command sets ERRORLEVEL to 1 if an attempt is made to
execute the COLOR command with a foreground and background colour
that are the same.
 Declare the variables y ,dd, m, nleap, count, scount, i=1, n.
 The first while loop is used to calculate the no. of days in a month like ,
for January it has 31 days etc…
 To print the days of a leap year we use the logic below,
A leap year is exactly divisible by 4 except for century years (years ending with
00). The century year is a leap year only if it is perfectly divisible by 400.

For example,

 1999 is not a leap year


 2000 is a leap year
 So if(y%4==0&&y%100!=0||y%400==0) is the condition for the if
statement.
 Next we use a switch case to print the no. of days for each months for the
given year.
 printf("\n\nMON TUE WED THURS FRI SAT SUN");
 Another switch case is used to print the corresponding dates to the
corresponding days in a month in a proper alignment.
 The user is asked to enter the desired year to display the calendar.
 Next the user is asked to enter a month and the value is assigned to the
variable n.
 To print the reminders of the given date a switch case is used and all the
reminders of the months are stored in it.
 So now the reminder of the entered day is displayed in the output.
 STOP

OUTLINE:
 Enter the desired year: xxxx
 Enter the month in that year: xx
 Enter a date to check for reminder: x
 Your reminder will be displayed.
START

INITIALIZE system(“color 5F”)


to get coloured output

Enter the year to display the


calendar

Enter the month of the given year

Read m

Switch(m)

NO NO NO NO
1 2 3 4
YES YES YES YES

Print “January” Print “February” Print “March” Print “April”

NO NO NO NO
8 7 6 5

YES YES YES YES

Print “August” Print “July” Print “June” Print “May”

NO NO NO
9 10 11 12
0
YES YES YES YES

Print “September” Print “October” Print “November” Print “December”

Enter a date to check for


STOP Print the reminder Read n
reminder
PROGRAM:

#include<stdio.h>

#include<conio.h>

void main()

{ system("color 5F");

int y,dd,m,nleap,count,scount,i=1,n;

long int dp;

printf("\n\t\t\t\t\t\t********###CALENDAR###********");

do

printf("\n\nPlease enter your desired year to display the calendar:


");

scanf("%d",&y);

}while(y<1);

do

printf("\nPlease enter the month: ");

scanf("%d",&m);

}while(m<1||m>12);

if(m==4||m==6||m==9||m==11)

{
dd=30;

if(y%4==0&&y%100!=0||y%400==0)

if(m==2)

dd=29;

else

if(m==2)

dd=28;

if(m==1||m==3||m==5||m==7||m==8||m==10||m==12)

dd=31;

nleap=(y-1)/4-(y-1)/100+(y-1)/400;

dp=(y-1)*365l+nleap;
switch(m)

case 12:dp+=30;

case 11:dp+=31;

case 10:dp+=30;

case 9:dp+=31;

case 8:dp+=31;

case 7:dp+=30;

case 6:dp+=31;

case 5:dp+=30;

case 4:dp+=31;

case 3:dp+=28;

case 2:dp+=31;

case 1:dp+=1;

switch(m)

case 1: if(m==1)

printf("\n---------JANUARY--------------");

break;

case 2: if(m==2)

printf("\n--------FEBRUARY--------------");

break;

case 3: if(m==3)
printf("\n--------MARCH-----------------");

break;

case 4: if(m==4)

printf("\n--------APRIL-----------------");

break;

case 5: if(m==5)

printf("\n---------MAY------------------");

break;

case 6: if(m==6)

printf("\n----------JUNE----------------");

break;

case 7: if(m==7)

printf("\n----------JULY----------------");

break;

case 8: if(m==8)

printf("\n--------AUGUST----------------");

break;

case 9: if(m==9)

printf("\n---------SEPTEMBER------------");

break;

case 10:if(m==10)

printf("\n--------OCTOBER----------------");

break;

case 11: if(m==11)


printf("\n--------NOVEMBER--------------");

break;

case 12: if(m==12)

printf("\n----------DECEMBER-----------");

break;

printf("\n\nMON TUE WED THURS FRI SAT SUN");

switch(dp%7)

case 1: count=0;

break;

case 2: count=4;

break;

case 3: count=8;

break;

case 4: count=12;

break;

case 5: count=16;

break;

case 6: count=20;

break;

default : count=24; //case 0: printf(" Sunday");

}
printf("\n");

scount=count;

while(scount>0)

printf(" ");

--scount;

while(dd>=i)

if(count%28==0)

printf("\n");

printf("%3d ",i);

i++;

count+=4;

printf("\n\nEnter a day to check for reminder: ");

scanf("%d",&n);

switch(m)

case 1:

{if(n==1)

printf("Yay!....New year is here");

else if(n==26)

printf("Republic day");
else if(n==15)

printf("Indian army day");

else if(n==25)

printf("National voter's day");

else if(n==24)

printf("National girl child day");

else

printf("\n\tNO REMINDER FOR THE GIVEN DAY");

break;

case 2:

if(n==13)

printf("World radio day");

else if(n==28)

printf("National science day");

else if(n==4)

printf("World cancer day");

else if(n==14)

printf("Valentine's day");

else if(n==22)

printf("World scout day");


else

printf("NO REMINDER FOR THE GIVEN DATE");

break;

case 3:

if(n==20)

printf("World sparrow day");

else if(n==8)

printf("International women's day");

else if(n==3)

printf("World wildlife day");

else if(n==15)

printf("Ramakrishna jayanthi");

else if(n==22)

printf("World water day");

else

printf("NO REMINDER FOR THE GIVEN DATE");

break;

case 4:

{
if(n==22)

printf("World earth day");

else if(n==23)

printf("World book and copyright day");

else if(n==7)

printf("World health day");

else if(n==14)

printf("B.R. Ambedkar Remembrance Day");

else if(n==2)

printf("World Autism Awareness Day");

else

printf("NO REMINDER FOR THE GIVEN DATE");

break;

case 5:

if(n==7)

printf("Rabindranath Tagore jayanthi");

else if(n==12)

printf("International Nurses day");

else if(n==5)

printf("May day");

else if(n==8)
printf("World red cross day");

else if(n==11)

printf("National technology day");

else

printf("NO REMINDER FOR THE GIVEN DATE");

break;

case 6:

if(n==5)

printf("World environment day");

else if(n==21)

printf("International yoga day");

else if(n==30)

printf("World asteroid day");

else if(n==7)

printf("World food safety day");

else if(n==29)

printf("National statistics day");

else

printf("NO REMINDER FOR THE GIVEN DATE");

break;

case 7:
{

if(n==11)

printf("World population day");

else if(n==18)

printf("International Nelson Mandela day");

else if(n==1)

printf("National doctor's day");

else if(n==30)

printf("International friendship day");

else if(n==29)

printf("International tiger day");

else

printf("NO REMINDER FOR THE GIVEN DATE");

break;

case 8:

if(n==15)

printf("Independence day");

else if(n==6)

printf("Hiroshima day");

else if(n==9)

printf("Nagasaki day");

else if(n==7)
printf("National handloom day");

else if(n==12)

printf("International youth day");

else

printf("NO REMINDER FOR THE GIVEN DATE");

break;

case 9:

if(n==29)

printf("World heart day");

else if(n==27)

printf("World tourism day");

else if(n==5)

printf("Teacher's day");

else if(n==10)

printf("World suicide prevention day");

else if(n==15)

printf("National engineer's day");

else

printf("NO REMINDER FOR THE GIVEN DATE");

break;

}
case 10:

if(n==2)

printf("Gandhi Jayanthi");

else if(n==16)

printf("World food day");

else if(n==31)

printf("National unity day");

else if(n==8)

printf("Indian air force day");

else if(n==10)

printf("World mental health day");

else

printf("NO REMINDER FOR THE GIVEN DATE");

break;

case 11:

if(n==19)

printf("International men's day");

else if(n==14)

printf("Children's day");

else if(n==7)
printf("National cancer awareness day");

else if(n==13)

printf("World kindness day");

else if(n==12)

printf("Guru nanak's birth anniversary");

else

printf("NO REMINDER FOR THE GIVEN DATE");

break;

case 12:

if(n==25)

printf("Christmas eve");

else if(n==24)

printf("National consumer rights day");

else if(n==10)

printf("Human rights day");

else if(n==1)

printf("World AIDS day");

else if(n==4)

printf("Indian navy day");

else

printf("NO REMINDER FOR THE GIVEN DATE");

break;
}

printf("\n\nHAVE A GOOD DAY!");

OUTPUT:

RESULT:

Thus, the above program to design a calendar with reminders and coloured
background is executed successfully and the output is verified.

TEAM MATES:

 REKHA P
 VINOTHA R

You might also like