0% found this document useful (0 votes)
78 views

Files: Program: Hotel Reservation System

This program is a library management system written in C/C++. It uses files to store data about books and students. Some key features include limiting students to borrowing no more than 5 books, allowing student numbers to contain letters, preventing reissuing books that have already been issued, and automatically calculating overdue fines of 50 paise per day after the due date. The program allows adding, deleting, and modifying book and student data as well as issuing and returning books.

Uploaded by

Sharma Pawan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views

Files: Program: Hotel Reservation System

This program is a library management system written in C/C++. It uses files to store data about books and students. Some key features include limiting students to borrowing no more than 5 books, allowing student numbers to contain letters, preventing reissuing books that have already been issued, and automatically calculating overdue fines of 50 paise per day after the due date. The program allows adding, deleting, and modifying book and student data as well as issuing and returning books.

Uploaded by

Sharma Pawan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 22

Program : Hotel Reservation System

/*
Language: C\C++
Category: Database\
Files

Description: Hotel Reservation


*/
#include
#include
#include
#include
#define size 51

void mainm(void);
void entry(void);
void modify(void);
void delet(void);
void view(void);

// Structure

struct hoteldata
{
char name[size][30], nic[size][20],rdate[size][12],cdate[size][12];
};

struct hoteldata guest;

struct hoteldata1
{
char name[size][30], nic[size][20],rdate[size][12],cdate[size][12];
};

struct hoteldata1 guest1;

// Initializations

int li,lp,sr[size];int dr[size];int rno;int i;int e;


char rc,ch,choice,echoice,rchoice,temp[80],vchoice,mf,ar;
// Main Fuction
void main(void)
{
clrscr();
sr[0]=1;dr[0]=1; // THE MAIN LOGIC !!

for(li=10;li=10;li--)
{
gotoxy(li,22);
delay(30);
printf("\\");
}
for(lp=16;lp<=21;lp++)
{
gotoxy(10,lp);
delay(100);
printf("-");
}
for(lp=21;lp>=16;lp--)
{
gotoxy(70,lp);
delay(100);
printf("=");
}
gotoxy(16,17);
textcolor(BLINK + MAGENTA);
cprintf("Welcome To The NALAIQUE's
Hotel Reservation
System");
gotoxy(12,20);
cprintf("Designed and Coded By NALAIQUE
Technologies
(C) 2002-2003");
gotoxy(36,28);
textcolor(LIGHTGREEN);
cprintf("Coded By");
gotoxy(24,31);
textcolor(2);
cprintf("Salman Javaid, # 31, BCS - 1 / B");
gotoxy(26,34);
textcolor(3);
cprintf("Irum Shahid, # 3, BCS - 1 / B");
textcolor(4);
gotoxy(22,37);
cprintf("Rabia Binte Aslam, # 61, BCS - 1 / B");
textcolor(5);
gotoxy(25,40);
textcolor(6);
cprintf("Rabia Latif, # 64, BCS - 1 / B");
gotoxy(44,48);
textcolor(WHITE);
cprintf("Press Any Key To ..........Continue");
getch();
mainm();
}// Main Fuction End

//Main Menu Function


void mainm(void)
{
clrscr();
for(li=30;li<=50;li++)
{
gotoxy(li,14);
delay(30);
printf("*");
}
for(li=50;li>=30;li--)
{
gotoxy(li,30);
delay(30);
printf("*");
}
for(lp=15;lp=15;lp--)
{
gotoxy(50,lp);
delay(100);
printf("|");
}
gotoxy(15,10);
textcolor(LIGHTGRAY);
cprintf("Press the corresponding Keys for the desired action");
gotoxy(33,16);
textcolor(BROWN);
cprintf("R:
Reservation
");
gotoxy(33,19);
textcolor(LIGHTMAGENTA);
cprintf("V: Room Status");
gotoxy(33,22);
textcolor(LIGHTBLUE);
cprintf("M: Modification");
gotoxy(33,25);
textcolor(LIGHTRED);
cprintf("D: Deletion");
gotoxy(33,28);
textcolor(GREEN);
cprintf("Q: Quit");
textcolor(WHITE);
choice=getch();
switch(choice)
{// Choice Switch Begin
case 'R':
entry();
case 'V':
view();
case 'M':
modify();
case 'D':
delet();
case 'Q':
exit(0);
default:
{//Choice Default
gotoxy(33,40);
printf("\n\nIllegal Choice or make sure CAPS Lock is on");
getch();
mainm();

}//Choice Default End


} //Choice Switch End
} //Main Menu Function End

// Data Entry Function


void entry(void)
{//Data Entry Function Begin
clrscr();
printf("Do You Want To reserve A Room? (Y/N)\n");
echoice=getch();
switch(echoice) // Echoice Switch Begin
{
case 'Y':
{ // E-Choice Case Y Begin
printf("\n\nEnter S for Single Room or D for Double Room\n\n");
rchoice=getch();
switch(rchoice) // Rchoice Switch Begin
{
case 'S': // Rchoice
{// R-Choice Case S Begin
for(i=1;i
Single Room
IF begin
clrscr();
sr[i]=1;
printf("\n\nRoom No : %d Is available For Reservation",i);
printf("\n\nEnter Occupant's Name\n");
gets(guest.name[i]);
printf("\n\nEnter Occupant's NIC Number\n");
gets(guest.nic[i]);
printf("\n\nEnter Check In Date\n");
gets(guest.rdate[i]);
printf("\n\nEnter Check Out Date\n");
gets(guest.cdate[i]);
printf("\n\n\n\nDo You Want To Reserve Another Room? Y/N");
ar=getch();
switch (ar)
{// AR Switch Begin
case 'Y':
entry();
case 'N':
mainm();
default:
{//AR Default Begin
printf("\n\nIllegal Choice or make sure CAPS Lock is on");
getch();
mainm();
}//AR Default End

}// AR Switch End


}// Single Room IF End
}// Rchoice Case S End

case 'D':
{ //Rchoice Case D Begin
for(i=1;i
Data Entry
Function End
// Data View Fucntion
void view(void)
{// Data View Function Begin
clrscr();
printf("Press S for Sequential Display of the room status \
\n\nPress R for Manual Check Of Room Status\n\n");
vchoice=getch();
switch(vchoice)
{//Vchoice Switch Begin
case 'S':
{//Vchoice Case S Begin
clrscr();
printf("R.No.\tName\t\tNIC Number\tCheck In\tCheck Out\n");
for(i=1;i51)
{//IF Condition Begin
printf("\n\nIllegal Room Number");
getch();
mainm();
} //IF Condition End
else
{ // Limit Else Falsified Begin
if(sr[rno]==1)
{//sr==1 if Begin
printf("\n\nSingle Room No %d Is Reserved",rno);
printf("\n\nOccupant's Name : %s \n\nOccupant's NIC Number : %s \
\n\nCheck In Date : %s\n\nCheck Out Date : %s \n\n", \
guest.name[rno],guest.nic[rno],guest.rdate[rno],guest.cdate[rno]);

}//sr==1 if End
else
{// sr else begin
printf("\n\nSingle Room No %d is Vacant",rno);
getch();
}//sr else end
if(dr[rno]==1)
{//dr==1 if Begin
printf("\n\nDouble Room No %d Is Reserved",rno);
printf("\nOccupant's Name : %s \n\nOccupant's NIC Number : \
%s \n\nCheck In Date : %s\n\nCheck Out Date : %s \n\n", \
guest1.name[rno],guest1.nic[rno],guest1.rdate[rno], \
guest1.cdate[rno]);
printf("\n\nPress Any Key To Return To The Main Menu");
getch();
mainm();
}//dr==1 if End
else
{// dr else begin
printf("\n\nDouble Room No %d is Vacant",rno);
getch();
mainm();
}//dr else end
}//Vchoice Case R End
}// Falsified Limit End
default:
{
//Vchoice Default Begin
printf("\n\nIllegal Choice or make sure CAPS Lock is on");
getch();
mainm();
} // Vchoice Default End
} // Vchoice Switch End
} // Data View Function End

//Modify Function
void modify(void)
{// Modify Function Begin
clrscr();
printf("\t\t\t\tData Modification\n\n\n\n\n\n");
printf("Enter The Room Number To Be Modified\n");
gets(temp);
rno=atoi(temp);
// Room Number Limit Check
if(rno51)
{//IF Condition Begin
printf("\n\nIllegal Room Number");
getch();
mainm();
} //IF Condition End
else
{ // Limit Else Falsified Begin
printf("Enter S For Single Room / D For Double Room\n");
rc=getch();
switch(rc)
{//rc Switch Begin
case 'S':
{//rc Case S Begin
if(sr[rno]==1)
{//sr==1 if Begin
clrscr();
printf("\n\nSingle Room No %d Is Reserved",rno);
printf("\n\nOccupant's Name : %s \n\nOccupant's NIC Number : \
%s \n\nCheck In Date : %s\n\nCheck Out Date : %s \n\n", \
guest.name[rno],guest.nic[rno],guest.rdate[rno],guest.cdate[rno]);

printf("\n\nPress N : Change Of Name\nI : Change In NIC\nR : \


Check In Date\nO : Check Out Date\n\n");
mf=getch();
switch(mf)
{//mf switch Begin
case 'N':
{//mf Case N Begin
printf("\n\nEnter New Name\n");
gets(guest.name[rno]);
getch();
mainm();
}//mf Case N End
case 'I':
{//mf Case I Begin
printf("\n\nEnter New NIC Number\n");
gets(guest.nic[rno]);
getch();
mainm();
}//mf Case I End
case 'R':
{//mf Case R Begin
printf("\n\nEnter New Check In Date\n");
gets(guest.rdate[rno]);
getch();
mainm();
}//mf Case R End
case 'O':
{//mf Case O Begin
printf("\n\nEnter New Check Out Date\n");
gets(guest.cdate[rno]);
getch();
mainm();
}//mf Case O End
default:
{//mf Default Begin
printf("\n\nInvalid Entry");
getch();
mainm();
}//mf Default End
}//sr==1 if End
} //rc Case S End
else
{// sr else begin
printf("\n\nSingle Room No %d is Vacant",rno);
getch();
mainm();
}//sr else end
}//rc Case S End
case 'D':
{// rc Case D Begin
if(dr[rno]==1)
{//dr==1 if Begin
clrscr();
printf("\n\nDouble Room No %d Is Reserved",rno);
printf("\n\nOccupant's Name : %s \n\nOccupant's NIC Number : \
%s \n\nCheck In Date : %s\n\nCheck Out Date : %s \n\n",\
guest1.name[rno],guest1.nic[rno],guest1.rdate[rno],\
guest1.cdate[rno]);

printf("\n\nPress N : Change Of Name\nI : Change \


In NIC\nR : Check In Date\nO : Check Out Date\n\n");
mf=getch();
switch(mf)
{//mf switch Begin
case 'N':
{//mf Case N Begin
printf("\n\nEnter New Name\n");
gets(guest1.name[rno]);
getch();
mainm();
}//mf Case N End
case 'I':
{//mf Case I Begin
printf("\n\nEnter New NIC Number\n");
gets(guest1.nic[rno]);
getch();
mainm();
}//mf Case I End
case 'R':
{//mf Case R Begin
printf("\n\nEnter New Check In Date\n");
gets(guest1.rdate[rno]);
getch();
mainm();
}//mf Case R End
case 'O':
{//mf Case O Begin
printf("\n\nEnter New Check Out Date\n");
gets(guest1.cdate[rno]);
getch();
mainm();
}//mf Case O End
default:
{//mf Default Begin
printf("\n\nIllegal Choice or make sure CAPS Lock is on");
getch();
mainm();
}//mf Default End
}//dr==1 if End
}//rc Case D End
else
{// dr else begin
printf("\n\nSingle Room No %d is Vacant",rno);
getch();
mainm();
}//dr else end
} // Case D End
default:
{// rc Default Begin
printf("\n\n\nIllegal Entry Or Make Sure CAPS Lock is On");
getch();
mainm();
} // rc Default End
} //Switch rc End
} // Limit Else Falsified End
} //Modify Function End

//Delete Function
void delet(void)
{//Delete Function
clrscr();
printf("Enter The Room Number To Vacate\n");
gets(temp);
rno=atoi(temp);

// Room Number Limit Check


if(rno51)
{//IF Condition Begin
printf("\n\nIllegal Room Number");
getch();
mainm();
} //IF Condition End
else
{// Room Number Limit Falsified Else
printf("\n\nSingle Or Double Room? (S/D)");
rc=getch();
switch(rc)
{//rc Switch Begin
case 'S':
{//rc Case S Begin
sr[rno]=0;
printf("\n\nRoom Vacated");
printf("\n\nPress Any Key To Exit To The Main Menu");
getch();
mainm();
}// rc Case S End
case 'D':
{//rc Case D Begin
dr[rno]=0;
printf("\n\nRoom Vacated");
printf("\n\nPress Any Key To Exit To The Main Menu");
getch();
mainm();
}//rc Case D End
default:
{//rc Default Begin
printf("\n\nIllegal Choice Or Make Sure CAPS Lock is ON");
getch();
mainm();
}// rc Default End
}// rc Switch End
}// Room Number Falsified Else End
}// Delete Function End

// END OF PROGRAM
Program : Library Management System

/*
Language: C\C++
Category: Database\Files
Description: LIBRARY MANAGEMENT
This is actually a library management software.it uses
files to store
data.it uses files to store data for later use.
-----------------FEATURES----------------------------------
*a student cannot borrow more than 5 books
*student number can contain alphabets(eg.02it65)
*issued book cannot be reissued
*fine is automatically calculated after 15 days.
(each day 50paise per day after the due date)
*book and student deatails can be viewed seperately.
*books which are issued/not issued can be viewed seperately.
*student and book details are stored in *.rrn files.
*there are two .rrn files(student.rrn and book.rrn the
*program uses)
*books and students can be added or removed.
*rrn is my own personal extension
*/

#include
#include
#include
#include
#include
#include
#include
#include
int display();
long int getsize(char[]);
void editb();
void edits();
void bkst();
void stst();
void issue();
void viewret();
void retbook();
void bklt();
void stlt();
typedef struct date DATE;
DATE dt,is,rt;
int dtest;
typedef struct
{
char sno[6];
char name[20];
float fine;
char dept[3];
int token;
}student;
typedef struct
{
char bno[5];
char bname[50];
char aname[20];
DATE iss;
DATE ret;
char status[1];
char isto[6];
int cost;
char descpt[200];
}book;
int id,im,iy,rd,rm,ry;
void assign(book *b)
{
b->iss.da_year=iy;
b->iss.da_mon=im;
b->iss.da_day=id;
b->ret.da_day=rd;
b->ret.da_mon=rm;
b->ret.da_year=ry;
return;
}
void main()
{
int opt;
clrscr();
while(1)
{
if(dtest!=1)
{
getdate(&dt);
is=dt;
rt=dt;
iy=is.da_year;
im=is.da_mon;
id=is.da_day;
rt.da_day+=15;
if(rt.da_day>31)
{
rt.da_day-=31;
rt.da_mon+=1;
}
rd=rt.da_day;
rm=rt.da_mon;
ry=rt.da_year;
dtest=1;
}
opt=display();
switch(opt)
{
case 1:
editb();
continue;
case 2:
edits();
continue;
case 3:
stst();
continue;
case 4:
bkst();
continue;
case 9:
stlt();
continue;
case 8:
bklt();
continue;
case 0:
exit(0);
break;
case 5:
issue();
continue;
case 7:
retbook();
continue;
case 6:
viewret();
continue;
default:
continue;
}
}
}
long int getsize(char a[])
{
int file,size;
file = open(a,O_RDONLY);
size=filelength(file);
close(file);
if (size<=(n+size)-1;i++)
{
int temp,flag=0;
printf("No. of the book:");
scanf("%s",(bk+i)->bno);
for(temp=0;tempbno,(bk+i)->bno);
if((int)cmp==0)
{
flag=1;
break;
}
}
if(flag==1)
{
printf("\nBook is aldready present!\n");
i--;
continue;
}
printf("Name of the book:");
scanf("%s",(bk+i)->bname);
printf("Author Name:");
scanf("%s",(bk+i)->aname);
printf("Enter the cost of the book:");
scanf("%d",&(bk+i)->cost);
(bk+i)->status[0]='N';
printf("Enter a short description :");
scanf("%s",(bk+i)->descpt);
}
fp=fopen("book.rrn","w+");
fwrite(bk,sizeof(book),(n+size),fp);
printf("%d book(s) added succesfully!",n);
fcloseall();
getch();
clrscr();
return;
case 2:
printf("\nEnter the number of the book:");
scanf("%s",bn);
if(size==0)
{
printf("Book list does not exist!");
getch();
clrscr();
return;
}
fp=fopen("book.rrn","r+");
fread(bk,sizeof(book),size,fp);
fcloseall();
for(i=0;ibno,strlen(bn))==0)
{
flag=1;
break;
}
}
if(flag!=1)
{
printf("\nThe entered book id is invalid.");
getch();
clrscr();
return;
}
if((bk+i)->status[0]=='Y')
{
printf("\nCannot delete the book.The book has \
been issued!");
getch();
return;
}
for(;i<=(n+size)-1;i++)
{
int temp,flag=0;
printf("No. of the student:");
scanf("%s",(st+i)->sno);
for(temp=0;tempsno,(st+temp)->sno,6);
if((int)cmp==0)
{
flag=1;
break;
}
}
if(flag==1)
{
printf("\nStudent aldready present in the list!\n");
i--;
continue;
}
printf("Name of the student:");
scanf("%s",(st+i)->name);
printf("Department:");
scanf("%s",(st+i)->dept);
(st+i)->token=0;
(st+i)->fine=0;
}
fp=fopen("student.rrn","w+");
fwrite(st,sizeof(student),(n+size),fp);
printf("%d student(s) added succesfully!",n);
fcloseall();
getch();
clrscr();
return;
case 2:
printf("\nEnter the number of the student:");
scanf("%s",bn);
if(size==0)
{
printf("Student list does not exist!");
getch();
clrscr();
return;
}
fp=fopen("student.rrn","r+");
fread(st,sizeof(student),size,fp);
fcloseall();
for(i=0;isno,strlen(bn))==0)
{
flag=1;
break;
}
}

if(flag!=1)
{
printf("\nThe entered student id is invalid.");
getch();
clrscr();
return;
}
if((st+i)->token>0)
{
printf("\nCannot delete the student.The student has borrowed\
books from library!");
getch();
return;
}
for(;isno,bn,6);
if((int)cmp==0)
{
flag=1;
break;
}
}
if(flag!=1)
{
printf("\nThe entered student id is invalid.");
getch();
clrscr();
return;
}
clrscr();
printf("\t\t\t\tSTUDENT DETAILS");
printf("\n\nStudent name:%s",(st+i)->name);
printf("\nDepartment:%s",(st+i)->dept);
printf("\nTokens Used: %d",(st+i)->token);
printf("\nFine:%.2f",(st+i)->fine);
if((st+i)->token==0)
{
getch();
clrscr();
return;
}
else if((st+i)->token!=0)
{
bsize1=getsize("book.rrn");
size1=(bsize1)/sizeof(book);
fp=fopen("book.rrn","r");
bk=(book*)malloc((size1)*sizeof(book));
fread(bk,sizeof(book),size1,fp);
fcloseall();
printf("\n\nBOOK(S) BORROWED FROM THE LIBRARY:\n");
for(i=0;iisto,6);
if((int)chk==0&&(bk+i)->status[0]=='Y')
printf("\nBook.No:%s\tBook Name:%s\t\nIssue:%d-%d-%d\t \
Expected Return:%d-%d-%d\n",
(bk+i)->bno,(bk+i)->bname,(bk+i)->iss.da_day,\
(bk+i)->iss.da_mon,(bk+i)->iss.da_year,

(bk+i)->ret.da_day,(bk+i)->ret.da_mon,(bk+i)->ret.da_year);
}
printf("\nPress any key........");
getch();
clrscr();
return;
}
}
void bkst()
{
int size,i,flag=0,bsize;
student *st;
book *bk;
FILE *fp;
char bn[6];
bsize=getsize("book.rrn");
size=(bsize)/sizeof(book);
bk=(book*)malloc((size)*sizeof(book));
printf("\nEnter the number of the book:");
scanf("%s",bn);
if(size==0)
{
printf("Book list does not exist!");
getch();
clrscr();
return;
}
fp=fopen("book.rrn","r+");
fread(bk,sizeof(book),size,fp);
fcloseall();
for(i=0;ibno,bn,6);
if((int)cmp==0)
{
flag=1;
break;
}
}
if(flag!=1)
{
printf("\nThe entered book id is invalid.");
getch();
clrscr();
return;
}
clrscr();
printf("\n\n\t\t\t\tBOOK DETAILS");
printf("\n\nBook name:%s",(bk+i)->bname);
printf("\n\nAuthor Name:%s",(bk+i)->aname);
printf("\n\nCost:Rs %d.00",(bk+i)->cost);
printf("\n\nDesciption:%s",(bk+i)->descpt);
if((bk+i)->status[0]=='Y')
{
char temp[6];
strncpy(temp,(bk+i)->isto,6);
printf("\n\nStatus:Issued");
printf("\n\nIssued to: %.6s",temp);
printf("\n\nDate of issue:%d/%d/%d",(bk+i)->iss.da_day, \
(bk+i)->iss.da_mon,(bk+i)->iss.da_year);

printf("\n\nExpected date of return:%d/%d/%d", \


(bk+i)->ret.da_day,(bk+i)->ret.da_mon,(bk+i)->ret.da_year);

}
else
printf("\n\nStatus:Not Issued");
getch();
clrscr();
return;
}
int display()
{
int op;
char msg[26];
clrscr();
printf("\t\t\t-LIBMAN-A Library Management Software-\n");
printf("\n\nDate :%d/%d/%d\n",dt.da_day,dt.da_mon,dt.da_year);
printf("\n1.Edit book list");
printf("\n2.Edit Student list");
printf("\n3.Student status");
printf("\n4.Book status");
printf("\n5.Issue");
printf("\n6.View books");
printf("\n7.Return Books");
printf("\n8.View book list");
printf("\n9.View student list");
strcpy(msg,"0.Exit\nEnter your choice:");
printf("\n%s",msg);
scanf("%d",&op);
return op;
}
void issue()
{
char bno[6],sno[6];
int size,bsize,i,flag=0,size1,bsize1,j,flag1=0,flag2=0,flag3=0;
char msg[22];
FILE *fp;
book *bk;
student *st;
flag1=flag2=flag=flag3=0;
strcpy(msg,"Enter the book number:");
printf("\n%s",msg);
scanf("%s",bno);
bsize=getsize("book.rrn");
size=bsize/sizeof(book);
if(size==0)
{
printf("\nBooklist does not exist!");
getch();
return;
}
fp=fopen("book.rrn","r+");
bk=(book*)malloc(size*sizeof(book));
fread(bk,sizeof(book),size,fp);
fcloseall();
for(i=0;ibno,strlen(bno));
if((int)temp==0)
{
flag=1;
break;
}
}
if((bk+i)->status[0]=='N')
flag3=1;
if(flag==1 && flag3==1)
{
printf("Enter the student no:");
scanf("%s",sno);
bsize1=getsize("student.rrn");
size1=bsize1/sizeof(student);
fp=fopen("student.rrn","r+");
st=(student*)malloc(size1*sizeof(student));
fread(st,sizeof(student),size1,fp);
fcloseall();
for(j=0;jsno,strlen(sno));
if(temp==0)
{
flag1=1;
break;
}
}
if(flag1==1&&flag==1)
{
if((st+j)->tokencost;
strcpy((bk+i)->isto,sno);
(bk+i)->status[0]='Y';
(bk+i)->cost=price;
assign(bk+i);
fwrite(bk,sizeof(book),size,fp);
fcloseall();
fp=fopen("student.rrn","w+");
(st+j)->token+=1;
fwrite(st,sizeof(student),size1,fp);
fcloseall();
getch();
}
}
}
if(flag!=1)
printf("\nInvalid Book Number!");
else if(flag3!=1)
printf("\nBook has aldready been issued!");
else if(flag1!=1)
printf("\nInvalid student number!");
else if(flag2!=1)
printf("\nTokens Exhausted!");
else
pri

You might also like