Movie Ticket Booking System
Movie Ticket Booking System
GROUP-7
Submitted by-
1-Mehul Kumar Jain(1706587)
2-Rajdeep Nagar(1706588)
3-Ankur Tiwari(1706589)
4-Vaibhav Jaipuriya(1706590)
5-Anunay Amrit(1706591)
6-Shivam Sharma(1706592)
7-Amit Kumar(1706593)
8-Avishek Das(1706594)
9-Mohit Kumar(1706595)
#include<stdio.h>
#include<stdlib.h>
void login()
{
int a=0,i=0;
char uname[10],c=' ';
char pword[10],code[10];
char user[10]="user";
char pass[10]="pass";
do
{printf("\n++++++++++++++++++++++++++++++LOGIN-FIRST+++++
+++++++++++++++++++++++++ ");
printf(" \n\n ENTER USERNAME:-");
scanf("%s", &uname);
printf(" \n\n ENTER PASSWORD:-");
while(i<10)
{
pword[i]=getch();
c=pword[i];
if(c==13) break;
else printf("*");
i++;
}
pword[i]='\0';
//char code=pword;
i=0;
//scanf("%s",&pword);
if(strcmp(uname,"user")==0&&strcmp(pword,"pass")==0)
{
printf("\n\n\n WELCOME TO OUR BOOKING SYSTEM !!!!
LOGIN IS SUCCESSFUL");
printf("\n\n\n\t\t\t\t Press any key to continue...");
getch();//holds the screen
break;
}
else
{
printf("\n SORRY !!!! LOGIN IS UNSUCESSFUL");
a++;
struct book
{
char code[20];
char name[20];
char date[20];
int cost;}b;
int seat = 60 ;
void insert_details();//for inserting movie details
void viewAll(); // for view all data
void find(); // for finding data
void book_ticket(); //for booking tickets
void old_record(); //for view old recorrds of users,booked
tickets
void main()
{
login();
int ch;
do{
printf("\n++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++");
printf("\n");
printf("\t Moive Ticket booking ");
printf("\n");
printf("\n++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++");
printf("\nEnter >1< To Insert Movie");
printf("\nEnter >2< To View All Movie");
printf("\nEnter >3< To Find Movie ");
printf("\nEnter >4< To Book Tickets");
printf("\nEnter >5< To View All Transactions");
printf("\nEnter >0< To Exit ");
printf("\nEnter your Choice ::");
scanf("%d",&ch); system("cls");
switch (ch)
{
case 1 :
insert_details();
break;
case 2:
viewAll();
break;
case 3:
find();
break;
case 4:
book_ticket();
break;
case 5:
old_record();
break;
case 0:
exit(0);
break;
default:
printf("Wrong choice !");
break;
}
}while(ch!=0);
}
void insert_details()
{
FILE *fp;
struct book b;
printf("Enter movie code :- ");
scanf("%s",b.code);
printf("Enter name :- ");
scanf("%s",b.name);
printf("Enter Release Date:- ");
scanf("%s",b.date);
printf("Enetr Ticket Price:- ");
scanf("%d",&b.cost);
fp=fopen("data.txt","a");
if(fp == NULL)
{
printf("FIle not Found");
}
else
{
fprintf(fp,"%s %s %s %d
\n",b.code,b.name,b.date,b.cost);
printf("Recorded Successfully");
}
printf("\n");
fclose(fp);
system("cls");
}
{
struct book b;
FILE *fp;
char ch[20];
printf("Enter movie code :");
scanf("%s",ch);
fp = fopen("data.txt","r");
if(fp == NULL)
{
printf("file does not found !");
exit(1);}
else
{
while(getc(fp) != EOF)
{
fscanf(fp,"%s %s %s %d",b.code,b.name,b.date,&b.cost);
if(strcmp(b.code,ch) == 0)
{
//printf("%s/%s/%s/%d\n",b.code,b.name,b.date,b.cost);
printf("\n Record Found\n");
printf("\n\t\tCode ::%s",b.code);
printf("\n\t\tmovie name ::%s",b.name);
printf("\n\t\tmovie date ::%s",b.date);
printf("\n\t\tprice of ticket ::%d",b.cost);
}
}
}
fclose(fp);
system("cls");
}
void viewAll()
{
char ch;
FILE *fp;
fp = fopen("data.txt","r");
if(fp == NULL)
{
printf("file does not found !");
exit(1);}
else
{
system("cls");
while( ( ch = fgetc(fp) ) != EOF )
printf("%c",ch);}
fclose(fp);
void book_ticket()
{
struct book b;
FILE *fp;
FILE *ufp;
int total_seat,mobile,total_amount;
char name[20];
//display ends
printf("\n For Book ticket Choice Movie(Enter Movie Code
First Latter Of Movie)\n");
printf("\n Enter movie code :");
scanf("%s",movie_code);
//system("clear");
fp = fopen("data.txt","r");
if(fp == NULL)
{
printf("file does not found !");
exit(1);}
else
{
while(getc(fp) != EOF)
{
fscanf(fp,"%s %s %s %d",b.code,b.name,b.date,&b.cost);
if(strcmp(b.code,movie_code) == 0)
{
//printf("%s / %s / %s
/ %d\n",b.code,b.name,b.date,b.cost);
printf("\n Record Found\n");
printf("\n\t\tCode ::%s",b.code);
printf("\n\t\tMovie name ::%s",b.name);
printf("\n\t\tdate name ::%s",b.date);
printf("\n\t\tPrice of ticket::%d",b.cost);
}
}
}
printf("\n* Fill Deatails *");
printf("\n your name :");
scanf("%s",name);
printf("\n mobile number :");
scanf("%d",&mobile);
printf("\n Total number of tickets :");
scanf("%d",&total_seat);
total_amount = b.cost * total_seat;
printf("\n ENJOY MOVIE \n");
printf("\n\t\tname : %s",name);
printf("\n\t\tmobile Number : %d",mobile);
printf("\n\t\tmovie name : %s",b.name);
printf("\n\t\tTotal seats : %d",total_seat);
printf("\n\t\tcost per ticket : %d",b.cost);
printf("\n\t\tTotal Amount : %d",total_amount);
ufp=fopen("oldTransection.txt","a");
if(ufp == NULL)
{
printf("FIle not Found");
}
else
{
fprintf(ufp,"%s %d %d %d %s %d
\n",name,mobile,total_seat,total_amount,b.name,b.cost);
printf("\n Record insert Sucessfull to the old record
file");
}
printf("\n");
fclose(ufp);
fclose(fp);}
//for view all user transaction
void old_record()
{ char ch;
FILE *fp; //system("clear");
fp = fopen("oldTransaction.txt","r");
if(fp == NULL)
{printf("file does not found !");
exit(1);}
else
{ system("cls");
while( ( ch = fgetc(fp) ) != EOF )
printf("%c",ch);}
fclose(fp);
}
Output: