daily pastebin goal
60%
SHARE
TWEET

Untitled

a guest May 23rd, 2018 111 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<string.h>
  4. #include<conio.h>
  5.  
  6. void worker();
  7. void login();
  8. void insertmovie();
  9. void viewAll();
  10. void bookticket();
  11. float addon();
  12.  
  13. int main()
  14. {
  15.     int choice;
  16.     login();
  17.     system("cls");
  18.  
  19.     do
  20.     {
  21.     printf("\n===================WELCOME TO 123 PANGGUNG=====================");
  22.     printf("\n===============================================================");
  23.     printf("\n");
  24.     printf("\nEnter >1< To Insert Movie");
  25.     printf("\nEnter >2< To View All Movie");//
  26.     printf("\nEnter >3< To Book Tickets");//
  27.  
  28.  
  29.     printf("\nEnter your Choice ::");
  30.     scanf("%d",&choice);
  31.     system("cls");
  32.  
  33.  
  34.     switch (choice)
  35.     {
  36.         case 1:
  37.         insertmovie();
  38.         break;
  39.  
  40.         case 2:
  41.         viewAll();
  42.         break;
  43.  
  44.         case 3:
  45.         bookticket();
  46.         break;
  47.  
  48.  
  49.  
  50.         default:
  51.         printf("Wrong choice !");
  52.         break;
  53.  
  54.     }
  55.  
  56.     }while (choice!=0);
  57. }
  58.  
  59. void login()
  60. {
  61.     int a=0,i=0;
  62.     char uname[10],c=' ';
  63.     char pword[10],code[10];
  64.     char user[10]="user";
  65.     char pass[10]="pass";
  66.     do
  67. {
  68.  
  69.     printf("\n  ============================  WORKER LOGIN  ============================  ");
  70.     printf(" \n\n                  ENTER USERNAME:-");
  71.     scanf("%s", &uname);
  72.     printf(" \n\n                  ENTER PASSWORD:-");
  73.     while(i<10)
  74.     {
  75.         pword[i]=getch();
  76.         c=pword[i];
  77.         if(c==13) break;
  78.         else printf("*");
  79.         i++;
  80.     }
  81.     pword[i]='\0';
  82.     //char code=pword;
  83.     i=0;
  84.     //scanf("%s",&pword);
  85.         if(strcmp(uname,"user")==0 && strcmp(pword,"pass")==0)
  86.     {
  87.  
  88.     printf("  \n\n\n       WELCOME TO OUR 123 PANGGUNG !!!! LOGIN IS SUCCESSFUL");
  89.     printf("\n\n\n\t\t\t\tPress any key to continue...");
  90.     getch();//holds the screen
  91.     break;
  92.     }
  93.     else
  94.     {
  95.         printf("\n        SORRY !!!!  LOGIN IS UNSUCESSFUL");
  96.         a++;
  97.  
  98.         getch();//holds the screen
  99.  
  100.     }
  101. }
  102.     while(a<=2);
  103.     if (a>2)
  104.     {
  105.         printf("\nSorry you have entered the wrong username and password for four times!!!");
  106.  
  107.         getch();
  108.  
  109.         }
  110. }
  111.  
  112. void insertmovie()
  113. {
  114.     char code[3],moviename[20];
  115.     float cost;
  116.  
  117.     FILE *insert;
  118.  
  119.     printf("Enter movie code : ");
  120.     scanf("%s",&code);
  121.     fflush(stdin);
  122.     printf("Enter movie name : ");
  123.     gets(moviename);
  124.     printf("Enter ticket price: ");
  125.     scanf("%f",&cost);
  126.  
  127.     insert=fopen("MovieList.txt","a");
  128.  
  129.     if(insert == NULL)
  130.     {
  131.         printf("FILE not Found");
  132.     }
  133.     else
  134.     {
  135.         fprintf(insert,"\n%s %s %.2f",code,moviename,cost);
  136.         printf("Recorded Successfully");
  137.     }
  138.     printf("\n");
  139.     fclose(insert);
  140.  
  141.     system("cls");
  142. }
  143.  
  144.  
  145. void viewAll()
  146. {
  147.  
  148.     char ch;
  149.     FILE *fp;
  150.  
  151.     fp = fopen("movieList.txt","r");
  152.     if(fp == NULL)
  153.     {
  154.         printf("file does not found !");
  155.         exit(1);
  156.     }
  157.     else
  158.     {
  159.         system("cls");
  160.         while( ( ch = fgetc(fp) ) != EOF )
  161.         printf("%c",ch);
  162.     }
  163.  
  164.     fclose(fp);
  165.  
  166. }
  167.  
  168.  
  169.  
  170. void bookticket()
  171. {
  172.     FILE *movie;
  173.     char code[3];
  174.     float cost,total_amount;
  175.     int total_seat,mobile;
  176.     char name[20];
  177.  
  178.     char ch; //used in display all movies
  179.     char movie_code[20]; //for searching
  180.     char code1[3];
  181.     char movieName[100];
  182.  
  183.     int caddon;
  184.     float totalAddon;
  185.  
  186.     movie = fopen("MovieList.txt","r");
  187.     if(movie == NULL)
  188.     {
  189.         printf("file does not found !");
  190.         exit(1);
  191.  
  192.     }
  193.     else
  194.     {
  195.         system("cls");
  196.         while( ( ch = fgetc(movie) ) != EOF )
  197.         printf("%c",ch);
  198.  
  199.     }
  200.     fclose(movie);
  201.  
  202.  
  203.  
  204.  
  205.     printf("\n For Book ticket Movie(Enter Movie Code First Letter Of Movie)\n");
  206.     printf("\n Enter movie code :");
  207.     scanf("%s",&code);
  208.     //system("clear");
  209.     movie = fopen("MovieList.txt","r");
  210.     if(movie == NULL)
  211.     {
  212.         printf("file does not found !");
  213.         exit(1);
  214.  
  215.     }
  216.     else
  217.     {
  218.         while(fscanf(movie,"%s %s %f",&code1,&movieName,&cost) != EOF)
  219.         {
  220.  
  221.             if(strcmp(code1, code) == 0)
  222.             {
  223.                 printf("\n Record Found\n");
  224.                 printf("\n\t\tCode :%s",code1);
  225.                 printf("\n\t\tMovie name :%s",movieName);
  226.                 printf("\n\t\tPrice of ticket :%.2f",cost);
  227.                 break;
  228.             }
  229.  
  230.         }
  231.     }
  232.     printf("\n\n* Fill Details  *");
  233.     fflush(stdin);
  234.     printf("\n your name :");
  235.     gets(name);
  236.     printf("\n mobile number :");
  237.     scanf("%d",&mobile);
  238.     printf("\n Total number of tickets :");
  239.     scanf("%d",&total_seat);
  240.  
  241.  
  242.     total_amount = cost * total_seat;
  243.  
  244.     printf("\nDo customer want to buy addon? : ");
  245.     printf("\n.1 for YES");
  246.     printf("\n.2 for NO");
  247.     scanf("%d", &caddon);
  248.  
  249.     do
  250.     {
  251.         if (caddon == 1)
  252.         {
  253.             totalAddon = addon();
  254.         }
  255.         else if (caddon > 2)
  256.         {
  257.             printf("\n\aEntered wrong input\n");
  258.         }
  259.  
  260.     }while (caddon > 2);
  261.  
  262.  
  263.  
  264.     system("cls");
  265.  
  266.     printf("\n ENJOY MOVIE \n");
  267.     printf("\n\t\tname : %s",name);
  268.     printf("\n\t\tmobile Number : %d",mobile);
  269.     printf("\n\t\tmovie name : %s",movieName);
  270.     printf("\n\t\tTotal seats : %d",total_seat);
  271.     printf("\n\t\tcost per ticket : %.2f",cost);
  272.     printf("\n\t\tTotal Amount : %.2f",total_amount);
  273.  
  274. }
  275.  
  276. float addon()
  277. {
  278.     int addon;
  279.     int flavour;
  280.     char itemName[15][50];
  281.     float itemPrice[15];
  282.    
  283.     printf("\nChoose addon : ");
  284.     printf("\n1. Popcorn");
  285.     printf("\n2. Drinks");
  286.     printf("\n3. Sausage\n");
  287.     scanf("%d", &addon);
  288.  
  289.     if (addon == 1)
  290.     {
  291.         printf("\nChoose popcorn flavour : ");
  292.         printf("\n1. Vanilla (RM -)");
  293.         printf("\n2. Chocolate (RM-)");
  294.         printf("\n3. Strawberry (RM-)\n");
  295.         scanf("%d", &flavour);
  296.        
  297.         if (flavour == 1)
  298.         {
  299.             strcpy(itemName[x], "Vanilla Popcorn");
  300.             itemPrice[x] = 0;//
  301.         }
  302.         else if (flavour == 2)
  303.         {
  304.             strcpy(itemName[x], "Chocolate Popcorn");
  305.             itemPrice[x] = 0;//
  306.         }
  307.         else if (flavour == 3)
  308.         {
  309.             strcpy(itemName[x], "Strawberry Popcorn");
  310.             itemPrice[x] = 0;//
  311.         }
  312.         else
  313.         {
  314.             strcpy(itemName[x], "INVALID ITEM");
  315.             itemPrice[x] = 0;
  316.         }
  317.  
  318.     }
  319.     else if (addon == 2)
  320.     {
  321.         printf("\nChoose drinks : ");
  322.         printf("\n1. Milo (RM-)");
  323.         printf("\n2. Coke (RM-)");
  324.         printf("\n3. Coffee (RM-)");
  325.         scanf("%d", flavour);
  326.        
  327.         if (flavour==1)
  328.         {
  329.             strcpy(itemName[x], "Milo Ice");
  330.             itemPrice[x] = 0;//
  331.         }
  332.        
  333.         else if (flavour==2)
  334.         {
  335.             strcpy(itemName[x], "Coke Ice");
  336.             itemPrice[x] = 0;//
  337.         }
  338.         else if (flavour==3)
  339.         {
  340.             strcpy(itemName[x], "Hot Coffee");
  341.             itemPrice[x] = 0;//
  342.         }
  343.         else
  344.         {
  345.             strcpy(itemName[x], "INVALID ITEM");
  346.             itemPrice[x] = 0;
  347.         }
  348.        
  349.     }
  350.     else if (addon == 3)
  351.     {
  352.        
  353.     }
  354.  
  355. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top