Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- #include<conio.h>
- void worker();
- void login();
- void insertmovie();
- void viewAll();
- void bookticket();
- float addon();
- int main()
- {
- int choice;
- login();
- system("cls");
- do
- {
- printf("\n===================WELCOME TO 123 PANGGUNG=====================");
- printf("\n===============================================================");
- printf("\n");
- printf("\nEnter >1< To Insert Movie");
- printf("\nEnter >2< To View All Movie");//
- printf("\nEnter >3< To Book Tickets");//
- printf("\nEnter your Choice ::");
- scanf("%d",&choice);
- system("cls");
- switch (choice)
- {
- case 1:
- insertmovie();
- break;
- case 2:
- viewAll();
- break;
- case 3:
- bookticket();
- break;
- default:
- printf("Wrong choice !");
- break;
- }
- }while (choice!=0);
- }
- 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 ============================ WORKER LOGIN ============================ ");
- 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 123 PANGGUNG !!!! LOGIN IS SUCCESSFUL");
- printf("\n\n\n\t\t\t\tPress any key to continue...");
- getch();//holds the screen
- break;
- }
- else
- {
- printf("\n SORRY !!!! LOGIN IS UNSUCESSFUL");
- a++;
- getch();//holds the screen
- }
- }
- while(a<=2);
- if (a>2)
- {
- printf("\nSorry you have entered the wrong username and password for four times!!!");
- getch();
- }
- }
- void insertmovie()
- {
- char code[3],moviename[20];
- float cost;
- FILE *insert;
- printf("Enter movie code : ");
- scanf("%s",&code);
- fflush(stdin);
- printf("Enter movie name : ");
- gets(moviename);
- printf("Enter ticket price: ");
- scanf("%f",&cost);
- insert=fopen("MovieList.txt","a");
- if(insert == NULL)
- {
- printf("FILE not Found");
- }
- else
- {
- fprintf(insert,"\n%s %s %.2f",code,moviename,cost);
- printf("Recorded Successfully");
- }
- printf("\n");
- fclose(insert);
- system("cls");
- }
- void viewAll()
- {
- char ch;
- FILE *fp;
- fp = fopen("movieList.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 bookticket()
- {
- FILE *movie;
- char code[3];
- float cost,total_amount;
- int total_seat,mobile;
- char name[20];
- char ch; //used in display all movies
- char movie_code[20]; //for searching
- char code1[3];
- char movieName[100];
- int caddon;
- float totalAddon;
- movie = fopen("MovieList.txt","r");
- if(movie == NULL)
- {
- printf("file does not found !");
- exit(1);
- }
- else
- {
- system("cls");
- while( ( ch = fgetc(movie) ) != EOF )
- printf("%c",ch);
- }
- fclose(movie);
- printf("\n For Book ticket Movie(Enter Movie Code First Letter Of Movie)\n");
- printf("\n Enter movie code :");
- scanf("%s",&code);
- //system("clear");
- movie = fopen("MovieList.txt","r");
- if(movie == NULL)
- {
- printf("file does not found !");
- exit(1);
- }
- else
- {
- while(fscanf(movie,"%s %s %f",&code1,&movieName,&cost) != EOF)
- {
- if(strcmp(code1, code) == 0)
- {
- printf("\n Record Found\n");
- printf("\n\t\tCode :%s",code1);
- printf("\n\t\tMovie name :%s",movieName);
- printf("\n\t\tPrice of ticket :%.2f",cost);
- break;
- }
- }
- }
- printf("\n\n* Fill Details *");
- fflush(stdin);
- printf("\n your name :");
- gets(name);
- printf("\n mobile number :");
- scanf("%d",&mobile);
- printf("\n Total number of tickets :");
- scanf("%d",&total_seat);
- total_amount = cost * total_seat;
- printf("\nDo customer want to buy addon? : ");
- printf("\n.1 for YES");
- printf("\n.2 for NO");
- scanf("%d", &caddon);
- do
- {
- if (caddon == 1)
- {
- totalAddon = addon();
- }
- else if (caddon > 2)
- {
- printf("\n\aEntered wrong input\n");
- }
- }while (caddon > 2);
- system("cls");
- printf("\n ENJOY MOVIE \n");
- printf("\n\t\tname : %s",name);
- printf("\n\t\tmobile Number : %d",mobile);
- printf("\n\t\tmovie name : %s",movieName);
- printf("\n\t\tTotal seats : %d",total_seat);
- printf("\n\t\tcost per ticket : %.2f",cost);
- printf("\n\t\tTotal Amount : %.2f",total_amount);
- }
- float addon()
- {
- int addon;
- int flavour;
- char itemName[15][50];
- float itemPrice[15];
- printf("\nChoose addon : ");
- printf("\n1. Popcorn");
- printf("\n2. Drinks");
- printf("\n3. Sausage\n");
- scanf("%d", &addon);
- if (addon == 1)
- {
- printf("\nChoose popcorn flavour : ");
- printf("\n1. Vanilla (RM -)");
- printf("\n2. Chocolate (RM-)");
- printf("\n3. Strawberry (RM-)\n");
- scanf("%d", &flavour);
- if (flavour == 1)
- {
- strcpy(itemName[x], "Vanilla Popcorn");
- itemPrice[x] = 0;//
- }
- else if (flavour == 2)
- {
- strcpy(itemName[x], "Chocolate Popcorn");
- itemPrice[x] = 0;//
- }
- else if (flavour == 3)
- {
- strcpy(itemName[x], "Strawberry Popcorn");
- itemPrice[x] = 0;//
- }
- else
- {
- strcpy(itemName[x], "INVALID ITEM");
- itemPrice[x] = 0;
- }
- }
- else if (addon == 2)
- {
- printf("\nChoose drinks : ");
- printf("\n1. Milo (RM-)");
- printf("\n2. Coke (RM-)");
- printf("\n3. Coffee (RM-)");
- scanf("%d", flavour);
- if (flavour==1)
- {
- strcpy(itemName[x], "Milo Ice");
- itemPrice[x] = 0;//
- }
- else if (flavour==2)
- {
- strcpy(itemName[x], "Coke Ice");
- itemPrice[x] = 0;//
- }
- else if (flavour==3)
- {
- strcpy(itemName[x], "Hot Coffee");
- itemPrice[x] = 0;//
- }
- else
- {
- strcpy(itemName[x], "INVALID ITEM");
- itemPrice[x] = 0;
- }
- }
- else if (addon == 3)
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement