Combined Calendar Application and Scientific Calculator

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

Department of Computer science

Kaliabor College, Kuwaitol

A
Project report on
“COMBINED CALENDAR APPLICATION AND
SCIENTIFIC CALCULATOR”

Submitted in Partial Fulfillment of the Requirements for the Degree of

BACHELOR OF COMPUTER APPLICATION


6th SEMESTER
GUWAHATI UNIVERSITY

GUIDED BY:- SUBMITTED BY:-


MR. AMIT DUTTA PULAK MANDAL
ASSISTANT PROFESSOR ROLL NO:- UT-181-300-0010
DEPT. OF COMPUTER SCIENCE REGISTRATION NO:- 18030682
KALIABOR COLLEGE BCA 6th SEMESTER
KALIABOR COLLEGE

1
Certificate

This is to certify that the project work entitled


“COMBINED CALENDAR APPLICATION AND SCIENTIFIC
CALCULATOR ” is done by PULAK MANDAL, Roll no: UT-
181-300-0010, a student of BCA 6th semester, kaliabor college
under my guidance. The work has been prepared as a partial
fulfillment of the requirements for the minor project of Bachelor
of Computer Application (BCA) 6th Semester of Kaliabor
College under Gauhati University.

During his association with me, I found that Pulak Mandal


was sincere in their works and I wish him all the best for his
future goals.

Respected External Sir Project Guide

Signature: …………… Signature:………….


(Amit Dutta)

2
ACKNOWLEDGMENT
I have taken efforts in this project entitled
“COMBINED CALENDAR APPLICATION AND SCIENTIFIC
CALCULATOR ”. However, it would not have been possible for
me without the kind support and help of many individuals and
my organization. I would like to extend my sincere thanks to all
of them.
I am highly indebted to thanks and gratitude most
sincerely and respectfully to our project guide Mr. Amit Dutta,
Assistant professor, Department of BCA, Kaliabor College for
his guidance and constant supervision as well as for providing
necessary information regarding the project and also for their
support in completing the project.
I would like to take the opportunity to express my deep
sense of gratitude to Mr. Dhrubajyoti Borah, Coordinator,
Department of BCA, Kaliabor College for giving us the
opportunity to carry out my project and for his valuable support
and advice.
Lastly I want to thank and appreciate also to my friends
who directly and indirectly willingly helped me out with their
ability to develop me in my project.
Pulak Mandal
ROLL NO: UT-191-300-0010
BCA 4th Semester
Dept. of BCA, Kaliabor College

3
ABSTRACT

The “Combined Calendar Application and Scientific


Calculator” presented here is a very simple console application
developed using C language. It is built using any graphics
properties; instead it utilizes many windows properties to give
the application a colorful look and feel. The project “Combined
Calendar Application and Scientific Calculator” is coded and
compiled in Dev-C++ using GCC Compiler.
The project calendar application can perform three
operations and the operations are as follow-
i) Find out the day of a particular date.
ii) Print all the day of a month.
iii) Add note to a particular date.

And the project Scientific Calculator can perform twenty


(20) operations and the operations are as follow-
i) Addition
ii) Subtraction
iii) Multiplication
iv) Division
v) Modulus
vi) Factorial
vii) Power
viii) Square
ix) Square root
x) Absolute
xi) Natural Logarithm

4
xii) Exponential Logarithm
xiii) Sine
xiv) Cosine
xv) Tann
xvi) Cosec
xvii) Sec
xviii) Cot
xix) Decimal to Binary
xx) Binary to Decimal

5
SL. NO. TOPIC NAME PAGE NO.

1. COVER PAGE 1

2. CERTIFICATE 2

3. ACKNOWLEDGEMT 3

4. ABSTRACT 4

5. TABLE OF CONTENT 5

6. PROJECT PROFILE 6

7. INTRODUCTION 7-8

8. FEATURES 9

9. SCREENSHOTS 10-12

10. SOURCE CODE 13-33

11. FUTURE SCOPE 34

12. REFERENCES 35

TABLE OF CONTENT

6
PROJECT PROFILE

Project Title : Combined Calendar Application


And Scientific Calculator
Objective : To develop a user friendly & efficient
System with that we can pre plan our
task to proceed a good routine of our
day. And to calculate our everyday life
mathematics easily and efficiently.

Operating system : Windows 10.

Software used : Dev-C++

Compiler : GCC Compiler.

Project Guide : Mr. Amit Dutta.

Submitted by : Pulak Mandal.

Roll No : UT-181-300-0010.

Registration no : 18030682

Submitted To : Department of BCA, Kaliabor College

7
INTRODUCTION

This Calendar Application is C language based project.


Basically three operations can be done in this calendar
application. And the operations are as follows-
1) To find out the day corresponding to a given date; the
date, month and year are asked. And the output is shown in
the screenshot below in Fig: 2.
2) we can list the days and dates of any month of any
year. For example, entering 12 1999 (December 1999) will give
us an output as shown in the screenshot below in Fig: 3.
We can navigate the months pressing ‘n’ and ‘p’ keys to
view the next and previous months respectively. And we can
quit by pressing ‘q’ key.
3) And the last feature of this Calendar Application is
utilization of file handling. With this feature, we can add
important notes with corresponding dates. And the
corresponding date where notes were added indicates with red
background on date as shown in Fig: 4 and Fig: 5 below. Also
we can see the notes by pressing the ‘s’ key.

The functions used in the source code are simple and


easy to understand. The ones listed below have been used to
produce background with color effects.

 void SetColor(intForgC)

 void ClearConsoleToColors(intForgC, intBackC)

8
 void SetColorAndBackground(intForgC, intBackC)
void gotoxy (int x, int y) – We need to understand this
function as it is an important one used in this Calendar in C
language. This function allows us to print text in any place of
screen. Using this function in Code::Blocks or Dev-C++ or other
ANSI C Compiler requires coding, but it can be directly used in
Turbo C. To use gotoxy() in Dev-C++ we have to use
#include<windows.h> and insert this snippet before the main()
function:

COORD xy = {0, 0}; // sets coordinates to (0,0)


As global variables
void gotoxy (int x, int y)
{
xy.X = x; xy.Y = y; // X and Y coordinates

SetConsoleCursorPosition(GetStdHandle(STD_OUT
PUT_HANDLE), xy);
}

9
FEATURES

The key features of this Calendar Application are:

 Windows properties have been used to make the overall


application colorful. Background Color is blue, the days of
a month are white, the vacations are red in color and the
notes that are added are red in background color.
 File handling has been used to this application to add
notes.
 It provides a very simple interface and displays days,
dates, months and year based on the input given by the
user.

10
SCREENSHOTS

In this section I have attached the screenshots of the output of


my project Calendar Application below:

Fig: 1

11
Fig: 2

Fig: 3

Fig: 4

12
Fig:5

13
SOURCE CODE

#include<stdio.h>
#include<conio.h>
#include<windows.h>

struct Date{
int dd;
int mm;
int yy;
};
struct Date date;

struct Remainder{
int dd;
int mm;
char note[50];
};
struct Remainder R;

14
COORD xy = {0, 0};

void gotoxy (int x, int y)


{
xy.X = x; xy.Y = y; // X and Y coordinates

SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HAN
DLE), xy);
}

//This will set the forground color for printing in a console


window.
void SetColor(int ForgC)
{
WORD wColor;
//We will need this handle to get the current background
attribute
HANDLE hStdOut =
GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;

//We use csbi for the wAttributes word.


if(GetConsoleScreenBufferInfo(hStdOut, &csbi))

15
{
//Mask out all but the background attribute, and add in the
forgournd color
wColor = (csbi.wAttributes & 0xF0) + (ForgC & 0x0F);
SetConsoleTextAttribute(hStdOut, wColor);
}
return;
}

void ClearColor(){
SetColor(15);
}

void ClearConsoleToColors(int ForgC, int BackC)


{
WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);
//Get the handle to the current output buffer...
HANDLE hStdOut =
GetStdHandle(STD_OUTPUT_HANDLE);
//This is used to reset the carat/cursor to the top left.
COORD coord = {0, 0};
//A return value... indicating how many chars were written

16
// not used but we need to capture this since it will be
// written anyway (passing NULL causes an access
violation).
DWORD count;

//This is a structure containing all of the console info


// it is used here to find the size of the console.
CONSOLE_SCREEN_BUFFER_INFO csbi;
//Here we will set the current color
SetConsoleTextAttribute(hStdOut, wColor);
if(GetConsoleScreenBufferInfo(hStdOut, &csbi))
{
//This fills the buffer with a given character (in this case
32=space).
FillConsoleOutputCharacter(hStdOut, (TCHAR) 32,
csbi.dwSize.X * csbi.dwSize.Y, coord, &count);

FillConsoleOutputAttribute(hStdOut, csbi.wAttributes,
csbi.dwSize.X * csbi.dwSize.Y, coord, &count );
//This will set our cursor position for the next print
statement.
SetConsoleCursorPosition(hStdOut, coord);
}

17
return;
}

void SetColorAndBackground(int ForgC, int BackC)


{
WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);;

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HAND
LE), wColor);
return;
}

int check_leapYear(int year){ //checks whether the year passed


is leap year or not
if(year % 400 == 0 || (year % 100!=0 && year % 4 ==0))
return 1;
return 0;
}

void increase_month(int *mm, int *yy){ //increase the month by


one
++*mm;
if(*mm > 12){

18
++*yy;
*mm = *mm - 12;
}
}

void decrease_month(int *mm, int *yy){ //decrease the month


by one
--*mm;
if(*mm < 1){
--*yy;
if(*yy<1600){
printf("No record available");
return;
}
*mm = *mm + 12;
}
}

int getNumberOfDays(int month,int year){ //returns the number


of days in given month
switch(month){ //and year

19
case 1 : return(31);
case 2 : if(check_leapYear(year)==1)
return(29);
else
return(28);
case 3 : return(31);
case 4 : return(30);
case 5 : return(31);
case 6 : return(30);
case 7 : return(31);
case 8 : return(31);
case 9 : return(30);
case 10: return(31);
case 11: return(30);
case 12: return(31);
default: return(-1);
}
}

char *getName(int day){ //returns the name of the day


switch(day){
case 0 :return("Sunday");

20
case 1 :return("Monday");
case 2 :return("Tuesday");
case 3 :return("Wednesday");
case 4 :return("Thursday");
case 5 :return("Friday");
case 6 :return("Saturday");
default:return("Error in getName() module.Invalid argument
passed");
}
}

void print_date(int mm, int yy){ //prints the name of month and
year
printf("---------------------------\n");
gotoxy(25,6);
switch(mm){
case 1: printf("January"); break;
case 2: printf("February"); break;
case 3: printf("March"); break;
case 4: printf("April"); break;
case 5: printf("May"); break;
case 6: printf("June"); break;

21
case 7: printf("July"); break;
case 8: printf("August"); break;
case 9: printf("September"); break;
case 10: printf("October"); break;
case 11: printf("November"); break;
case 12: printf("December"); break;
}
printf(" , %d", yy);
gotoxy(20,7);
printf("---------------------------");
}
int getDayNumber(int day,int mon,int year){ //retuns the day
number
int res = 0, t1, t2, y = year;
year = year - 1600;
while(year >= 100){
res = res + 5;
year = year - 100;
}
res = (res % 7);
t1 = ((year - 1) / 4);
t2 = (year-1)-t1;

22
t1 = (t1*2)+t2;
t1 = (t1%7);
res = res + t1;
res = res%7;
t2 = 0;
for(t1 = 1;t1 < mon; t1++){
t2 += getNumberOfDays(t1,y);
}
t2 = t2 + day;
t2 = t2 % 7;
res = res + t2;
res = res % 7;
if(y > 2000)
res = res + 1;
res = res % 7;
return res;
}

char *getDay(int dd,int mm,int yy){


int day;
if(!(mm>=1 && mm<=12)){
return("Invalid month value");

23
}
if(!(dd>=1 && dd<=getNumberOfDays(mm,yy))){
return("Invalid date");
}
if(yy>=1600){
day = getDayNumber(dd,mm,yy);
day = day%7;
return(getName(day));
}else{
return("Please give year more than 1600");
}
}

int checkNote(int dd, int mm){


FILE *fp;
fp = fopen("note.dat","rb");
if(fp == NULL){
printf("Error in Opening the file");
}
while(fread(&R,sizeof(R),1,fp) == 1){
if(R.dd == dd && R.mm == mm){
fclose(fp);

24
return 1;
}
}
fclose(fp);
return 0;
}

void printMonth(int mon,int year,int x,int y){ //prints the month


with all days
int nod, day, cnt, d = 1, x1 = x, y1 = y, isNote = 0;
if(!(mon>=1 && mon<=12)){
printf("INVALID MONTH");
getch();
return;
}
if(!(year>=1600)){
printf("INVALID YEAR");
getch();
return;
}
gotoxy(20,y);
print_date(mon,year);

25
y += 3;
gotoxy(x,y);
printf("S M T W T F S ");
y++;
nod = getNumberOfDays(mon,year);
day = getDayNumber(d,mon,year);
switch(day){ //locates the starting day in calender
case 0 :
x=x;
cnt=1;
break;
case 1 :
x=x+4;
cnt=2;
break;
case 2 :
x=x+8;
cnt=3;
break;
case 3 :
x=x+12;
cnt=4;

26
break;
case 4 :
x=x+16;
cnt=5;
break;
case 5 :
x=x+20;
cnt=6;
break;
case 6 :
x=x+24;
cnt=7;
break;
default :
printf("INVALID DATA FROM THE
getOddNumber()MODULE");
return;
}
gotoxy(x,y);
if(cnt == 1){
SetColor(12);
}

27
if(checkNote(d,mon)==1){
SetColorAndBackground(15,12);
}
printf("%02d",d);
SetColorAndBackground(15,1);
for(d=2;d<=nod;d++){
if(cnt%7==0){
y++;
cnt=0;
x=x1-4;
}
x = x+4;
cnt++;
gotoxy(x,y);
if(cnt==1){
SetColor(12);
}else{
ClearColor();
}
if(checkNote(d,mon)==1){
SetColorAndBackground(15,12);
}

28
printf("%02d",d);
SetColorAndBackground(15,1);
}
gotoxy(8, y+2);
SetColor(14);
printf("Press 'n' to Next, Press 'p' to Previous and 'q' to
Quit");
gotoxy(8,y+3);
printf("Red Background indicates the NOTE, Press 's' to see
note: ");
ClearColor();
}

void AddNote(){
FILE *fp;
fp = fopen("note.dat","ab+");
system("cls");
gotoxy(5,7);
printf("Enter the date(DD/MM): ");
scanf("%d%d",&R.dd, &R.mm);
gotoxy(5,8);
printf("Enter the Note(50 character max): ");

29
fflush(stdin);
scanf("%[^\n]",R.note);
if(fwrite(&R,sizeof(R),1,fp)){
gotoxy(5,12);
puts("Note is saved sucessfully");
fclose(fp);
}else{
gotoxy(5,12);
SetColor(12);
puts("\aFail to save!!\a");
ClearColor();
}
gotoxy(5,15);
printf("Press any key............");
getch();
fclose(fp);
}

void showNote(int mm){


FILE *fp;
int i = 0, isFound = 0;
system("cls");

30
fp = fopen("note.dat","rb");
if(fp == NULL){
printf("Error in opening the file");
}
while(fread(&R,sizeof(R),1,fp) == 1){
if(R.mm == mm){
gotoxy(10,5+i);
printf("Note %d Day = %d: %s", i+1, R.dd, R.note);
isFound = 1;
i++;
}
}
if(isFound == 0){
gotoxy(10,5);
printf("This Month contains no note");
}
gotoxy(10,7+i);
printf("Press any key to back.......");
getch();

31
int main(){
ClearConsoleToColors(15, 1);
SetConsoleTitle("Calender Application by Pulak Mandal");
int choice;
char ch = 'a';
while(1){
system("cls");
printf("1. Find Out the Day\n");
printf("2. Print all the day of month\n");
printf("3. Add Note\n");
printf("4. EXIT\n");
printf("ENTER YOUR CHOICE : ");
scanf("%d",&choice);
system("cls");
switch(choice){
case 1:
printf("Enter date (DD MM YYYY) : ");
scanf("%d %d %d",&date.dd,&date.mm,&date.yy);
printf("Day is :
%s",getDay(date.dd,date.mm,date.yy));
printf("\nPress any key to continue......");
getch();

32
break;
case 2 :
printf("Enter month and year (MM YYYY) : ");
scanf("%d %d",&date.mm,&date.yy);
system("cls");
while(ch!='q'){
printMonth(date.mm,date.yy,20,5);
ch = getch();
if(ch == 'n'){
increase_month(&date.mm,&date.yy);
system("cls");
printMonth(date.mm,date.yy,20,5);
}else if(ch == 'p'){
decrease_month(&date.mm,&date.yy);
system("cls");
printMonth(date.mm,date.yy,20,5);
}else if(ch == 's'){
showNote(date.mm);
system("cls");
}
}
break;

33
case 3:
AddNote();
break;
case 4 :
exit(0);
}
}
return 0;
}

34
FUTURE SCOPE

Initially this minor project was very new to me but I


tried my best and gave my full effort to complete this project on
time. There may be some issue or problem with this project; in
the future step I will try to solve those unnecessary issues.
In the future scope, I will try to update this application and
add digital clock along with calendar, and also there will be
option for remainder.

35
REFERENCES

BOOKS:-

 The C Programming Language by Kernighan and Ritchie.


 C Programming and Coding by Swati Saxena.

WEBSITES:-
 www.codewithc.com
 www.geeksforgeeks.com
 https://mobile.happycodings.com

:::::::::::::::::::::X::::::::::::::::::::

36

You might also like