1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347
|
#include<iostream.h>
#include<conio.h>
#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
{
cout<<"\n ++++++++++++++++++++++++++++++ LOGIN FIRST ++++++++++++++++++++++++++++++ ";
cout<<" \n\n ENTER USERNAME:-";
gets(uname);
cout<<" \n\n ENTER PASSWORD:-";
while(i<10)
{
pword[i]=getch();
c=pword[i];
if(c==13)
break;
else
cout<<"*";
i++;
}
pword[i]='\0';
//char code=pword;
i=0;
if(strcmp(uname,"user")==0 && strcmp(pword,"pass")==0)
{
cout<<"\n\n\nWELCOME TO OUR BOOKING SYSTEM !!!! LOGIN IS SUCCESSFUL";
cout<<"\n\n\n\t\t\t\tPress any key to continue...";
getch();//holds the screen
break;
}
else
{
cout<<"\n SORRY !!!! LOGIN IS UNSUCESSFUL";
a++;
getch();//holds the screen
}
}
while(a<=2);
if (a>2)
{
cout<<"\nSorry you have entered the wrong username and password for four times!!!";
getch();
}
system("cls");
}
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
{
cout<<"\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++";
cout<<"\n";
cout<<"\t Moive Ticket booking ";
cout<<"\n";
cout<<"\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++";
cout<<"\nEnter >1< To Insert Movie";
cout<<"\nEnter >2< To View All Movie";
cout<<"\nEnter >3< To Find Movie ";
cout<<"\nEnter >4< To Book Tickets";
cout<<"\nEnter >5< To View All Transactions";
cout<<"\nEnter >0< To Exit ";
cout<<"\nEnter your Choice ::";
cin>>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:
cout<<"Wrong choice !";
break;
}
}while(ch!=0);
}
void insert_details()
{
FILE *fp;
struct book b;
cout<<"Enter movie code :- ";
gets(b.code);
cout<<"Enter name :- ";
gets(b.name);
cout<<"Enter Release Date:- ";
gets(b.date);
cout<<"Enetr Ticket Price:- ";
cin>>b.cost;
fp=fopen("data.txt","a");
if(fp == NULL)
{
cout<<"FIle not Found";
}
else
{
cout<<"\n"<<b.code<<" "<<b.name<<" "<<b.date<<" "<<b.cost;
cout<<"Recorded Successfully";
}
cout<<"\n";
fclose(fp);
system("cls");
}
void find() //find details
{
struct book b;
FILE *fp;
char ch[20];
cout<<"Enter movie code :";
cin>>ch;
fp = fopen("data.txt","r");
if(fp == NULL)
{
cout<<"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)
{
cout<<"\n Record Found\n";
cout<<"\n\t\tCode ::"<<b.code;
cout<<"\n\t\tmovie name ::"<<b.name;
cout<<"\n\t\tmovie date ::"<<b.date;
cout<<"\n\t\tprice of ticket ::"<<b.cost;
}
}
}
fclose(fp);
system("cls");
}
void viewAll()
{
char ch;
FILE *fp;
fp = fopen("data.txt","r");
if(fp == NULL)
{
cout<<"file does not found !";
exit(1);
}
else
{
system("cls");
while( ( ch = fgetc(fp) ) != EOF )
cout<<ch;
}
fclose(fp);
}
//for ticket booking
void book_ticket()
{
struct book b;
FILE *fp;
FILE *ufp;
int total_seat,mobile,total_amount;
char name[20];
char ch; //used in display all movies
char movie_code[20]; //for searching
// disply all moives by default for movie code
fp = fopen("data.txt","r");
if(fp == NULL)
{
cout<<"file does not found !";
exit(1);
}
else
{
system("cls");
while( ( ch = fgetc(fp) ) != EOF )
cout<<ch;
}
fclose(fp);
//display ends
cout<<"\n For Book ticket Choice Movie(Enter Movie Code First Latter Of Movie)\n";
cout<<"\n Enter movie code :";
gets(movie_code);
fp = fopen("data.txt","r");
if(fp == NULL)
{
cout<<"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)
{
cout<<"\n Record Found\n";
cout<<"\n\t\tCode ::"<<b.code;
cout<<"\n\t\tMovie name ::"<<b.name;
cout<<"\n\t\tdate name ::"<<b.date;
cout<<"\n\t\tPrice of ticket::"<<b.cost;
}
}
}
cout<<"\n* Fill Deatails *";
cout<<"\n your name :";
gets(name);
cout<<"\n mobile number :";
cin>>mobile;
cout<<"\n Total number of tickets :";
cin>>total_seat;
total_amount = b.cost * total_seat;
cout<<"\n ENJOY MOVIE \n";
cout<<"\n\t\tname :<<name;
cout<<"\n\t\tmobile Number :<<mobile;
cout<<"\n\t\tmovie name :<<b.name;
cout<<"\n\t\tTotal seats :<<total_seat;
cout<<"\n\t\tcost per ticket :<<b.cost;
cout<<"\n\t\tTotal Amount :<<total_amount;
ufp=fopen("oldTransection.txt","a");
if(ufp == NULL)
{
cout<<"FIle not Found";
}
else
{
fprintf(ufp,"%s %d %d %d %s %d \n",name,mobile,total_seat,total_amount,b.name,b.cost);
cout<<"\n Record insert Sucessfull to the old record file";
}
cout<<"\n";
fclose(ufp);
fclose(fp);
}
//for view all user transections
void old_record()
{
char ch;
FILE *fp;
//system("clear");
fp = fopen("oldTransection.txt","r");
if(fp == NULL)
{
cout<<"file does not found !";
exit(1);
}
else
{
system("cls");
while( ( ch = fgetc(fp) ) != EOF )
cout<<ch;
}
fclose(fp);
}
|