Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.93 KB | None | 0 0
  1. // Developer: Md. Mahfuzur Rahman ( Mahfuz77 )
  2. // Dept of CSE
  3. // Daffodil International University,Bangladesh
  4. // Project: Bus Reservation System
  5. // Language: C
  6. // Date : 10-12-2015
  7.  
  8.  
  9.  
  10.  
  11. #include<stdio.h>
  12. #include<conio.h>
  13. #include<string.h>
  14.  
  15. void display();
  16. void ticket();
  17. void seat_details();
  18. int seat_booking();
  19. int x,i,c,j,p,m[40],cnt=0,l,n,booked_seat=NULL,t,ext,k,start,end;
  20. char ch[10],seat_num[4],num[12];
  21.  
  22.  
  23. struct bus
  24. {
  25. char bus_name[10];
  26. float bus_time;
  27. char departure[10];
  28. char destination[15];
  29. float price;
  30.  
  31. }data[2];
  32.  
  33.  
  34. struct seat
  35. {
  36. char seat[3];
  37.  
  38. }st[40],a[40];
  39.  
  40.  
  41. int main()
  42. {
  43. int chc;
  44. printf("\n\t\t\t-------->>>> Project: Bus Reservation System <<<<-------\n\n\n");
  45. printf("\n-----------------------------------WELCOME TO \"FRIEND EXPRESS\"------------------------------ \n\n");
  46. printf("--------------------------------------------------------------------------------------------\n");
  47.  
  48. printf("\n\t\t\t\t\tAdmin :1 User:2");
  49. printf("\n\nEnter your choice:");
  50. scanf("%d",&chc);
  51.  
  52. if(chc==1)
  53.  
  54. {
  55. char ky[5];
  56. FILE *pas;
  57. int u,v,x;
  58.  
  59.  
  60. char name[10];
  61. char pass[5];
  62. printf("\nUser Name:");
  63. scanf("%s",name);
  64. v=strcmp(name,"f_express");
  65.  
  66. printf("\nPassward:");
  67. scanf("%s",pass);
  68.  
  69. pas=fopen("password.txt","r");
  70. fscanf(pas,"%s",ky);
  71. fclose(pas);
  72.  
  73.  
  74. u=strcmp(pass,ky);
  75.  
  76. if(u==0&&v==0)
  77. {
  78. printf("\nAdmin Login successfull\n");
  79.  
  80. printf("\n\nTo change password press 1:");
  81. //printf("\n\nTo refresh all data press 2:");
  82.  
  83. printf("\n\nInput pls:");
  84. scanf("%d",&x);
  85. if(x==1)
  86. {
  87. pas=fopen("password.txt","w");
  88. printf("\n\nEnter your new password:");
  89. scanf("%s",ky);
  90. fprintf(pas,"%s",ky);
  91. fclose(pas);
  92. printf("\n\n>>>>>>>>>>>>>>Password changed sucessfully<<<<<<<<<<<\n\n");
  93. printf("\n\n>>>>>>>>>>>>>>Thank You<<<<<<<<<<<\n\n");
  94. }
  95.  
  96. /*if(x==2)
  97. {
  98. remove(ticket.txt);
  99. }*/
  100.  
  101. }
  102.  
  103. else
  104. printf("\nyou are not an Admin\n");
  105.  
  106.  
  107. }
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117. if(chc==2)
  118. {
  119. int len;
  120.  
  121.  
  122.  
  123. printf("\nEnter your mobile number to login:");
  124. scanf("%s",num);
  125.  
  126. printf("\nYour Number is: %s\n\n",num);
  127.  
  128. if(num[0]=='0'&&num[1]=='1'&&num[2]=='7'||num[2]=='8'||num[2]=='9'||num[2]=='6'||num[2]=='5'||num[2]=='1')
  129. {
  130.  
  131. len=strlen(num);
  132.  
  133. if(len==11)
  134. {
  135. printf("Login successfull\n\n\n");
  136.  
  137. //Add full Code HERE
  138.  
  139.  
  140. printf("Bus_name\t\t");
  141. printf("Departure time\t\t");
  142. printf("Departure\t\t");
  143. printf("Destination\t\t");
  144. printf("price\n");
  145. printf("------------***--------------------------***------------------***--------------------***--------------\n");
  146.  
  147. strcpy(data[0].bus_name,"fe-1");
  148. data[0].bus_time=9.0;
  149. strcpy(data[0].departure,"Dhaka");
  150. strcpy(data[0].destination,"Kustia");
  151. data[0].price=500.0;
  152.  
  153.  
  154. strcpy(data[1].bus_name,"fe-2");
  155. data[1].bus_time=11.0;
  156. strcpy(data[1].departure,"Dhaka");
  157. strcpy(data[1].destination,"Sylhet");
  158. data[1].price=800.0;
  159.  
  160.  
  161. strcpy(data[2].bus_name,"fe-3");
  162. data[2].bus_time=12.0;
  163. strcpy(data[2].departure,"Dhaka");
  164. strcpy(data[2].destination,"Ctg.");
  165. data[2].price=1000.0;
  166.  
  167. for(i=0;i<=2;i++)
  168. {
  169. printf("%s\t\t\t%.2f\t\t\t%s\t\t\t%s\t\t\t%.2f\n\n",data[i].bus_name,data[i].bus_time,data[i].departure,data[i].destination,data[i].price);
  170.  
  171. }
  172.  
  173. seat_details();
  174.  
  175.  
  176. }
  177. else
  178. printf("\nInvalid phone number\n");
  179.  
  180. }
  181.  
  182. else
  183. printf("\nInvalid phone number\n");
  184.  
  185. }
  186.  
  187. return 0;
  188. }
  189.  
  190.  
  191. void seat_details()
  192.  
  193. {
  194.  
  195.  
  196. strcpy(st[0].seat,"A1");
  197. strcpy(st[1].seat,"A2");
  198. strcpy(st[2].seat,"A3");
  199. strcpy(st[3].seat,"A4");
  200. strcpy(st[4].seat,"B1");
  201. strcpy(st[5].seat,"B2");
  202. strcpy(st[6].seat,"B3");
  203. strcpy(st[7].seat,"B4");
  204. strcpy(st[8].seat,"C1");
  205. strcpy(st[9].seat,"C2");
  206. strcpy(st[10].seat,"C3");
  207. strcpy(st[11].seat,"C4");
  208. strcpy(st[12].seat,"D1");
  209. strcpy(st[13].seat,"D2");
  210. strcpy(st[14].seat,"D3");
  211. strcpy(st[15].seat,"D4");
  212. strcpy(st[16].seat,"E1");
  213. strcpy(st[17].seat,"E2");
  214. strcpy(st[18].seat,"E3");
  215. strcpy(st[19].seat,"E4");
  216. strcpy(st[20].seat,"F1");
  217. strcpy(st[21].seat,"F2");
  218. strcpy(st[22].seat,"F3");
  219. strcpy(st[23].seat,"F4");
  220. strcpy(st[24].seat,"G1");
  221. strcpy(st[25].seat,"G2");
  222. strcpy(st[26].seat,"G3");
  223. strcpy(st[27].seat,"G4");
  224. strcpy(st[28].seat,"H1");
  225. strcpy(st[29].seat,"H2");
  226. strcpy(st[30].seat,"H3");
  227. strcpy(st[31].seat,"H4");
  228. strcpy(st[32].seat,"I1");
  229. strcpy(st[33].seat,"I2");
  230. strcpy(st[34].seat,"I3");
  231. strcpy(st[35].seat,"I4");
  232. strcpy(st[36].seat,"J1");
  233. strcpy(st[37].seat,"J2");
  234. strcpy(st[38].seat,"J3");
  235. strcpy(st[39].seat,"J4");
  236.  
  237.  
  238.  
  239.  
  240.  
  241. printf("\n\nTo See Available Seat Of Particular Bus Enter Bus Name:");
  242. scanf("%s",ch);
  243.  
  244. printf("\n\n------------------------------------------------------------------\n\n");
  245.  
  246. FILE *fp,*fq,*fr,*fs,*ft,*fa,*fb,*fc,*fd,*fe,*ff,*fg,*fh,*fi,*fj;
  247.  
  248. fp=fopen("check.txt","r");
  249. fclose(fp);
  250.  
  251. fa=fopen("a.txt","r");
  252. fclose(fa);
  253.  
  254. ff=fopen("f.txt","r");
  255. fclose(ff);
  256.  
  257.  
  258.  
  259.  
  260.  
  261. if(strcmp(data[0].bus_name,ch)==0)
  262.  
  263.  
  264.  
  265. {
  266.  
  267. if(fp==NULL)
  268. {
  269.  
  270. printf("-------+++-----AVAILABLE SEAT------+++-----\n\n");
  271.  
  272. for(i=0;i<=39;i++)
  273. {
  274.  
  275.  
  276. printf("%s\t",st[i].seat);
  277.  
  278. if(i==3||i==7||i==11||i==15||i==19||i==23||i==27||i==31||i==35)
  279. {
  280. printf("\n\n");
  281. }
  282.  
  283.  
  284.  
  285.  
  286.  
  287. }
  288.  
  289. }
  290.  
  291. else
  292. {
  293. p=0;
  294. printf("---***----AVAILABLE SEAT----***---\n\n");
  295. fp=fopen("check.txt","r");
  296. for(i=0;i<=39;i++)
  297. {
  298.  
  299. fscanf(fp,"%s ",st[i].seat);
  300.  
  301. }
  302.  
  303. for(i=0;i<=39;i++)
  304. {
  305.  
  306.  
  307. printf("%s\t",st[i].seat);
  308.  
  309. if(i==3||i==7||i==11||i==15||i==19||i==23||i==27||i==31||i==35)
  310. {
  311. printf("\n\n");
  312. }
  313.  
  314. }
  315.  
  316.  
  317. fclose(fp);
  318. }
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327. do
  328. {
  329. p=0;
  330. l=0;
  331.  
  332.  
  333. printf("\n\nTo Book Seat Press-->>>:1\nTo Exit Press--->>>>>:2\n\n");
  334. printf("Pls Press------->>>>>:");
  335.  
  336. scanf("%d",&ext);
  337.  
  338. if(ext==1)
  339. {
  340.  
  341.  
  342. printf("\n\n-----------BOOK YOUR SEAT NOW--------------\n\n");
  343.  
  344. printf("Enter Seat Num:");
  345. scanf("%s",seat_num);
  346.  
  347.  
  348. fq=fopen("count.txt","r");
  349. fclose(fq);
  350.  
  351.  
  352. if(fq==NULL)
  353. {
  354. for(i=0;i<=39;i++)
  355. {
  356. c=strcmp(st[i].seat,seat_num);
  357. if(c==0)
  358. {
  359. strcpy(a[cnt].seat,st[i].seat);
  360.  
  361. fr=fopen("ticket.txt","w");
  362. fprintf(fr,"%s ",st[i].seat);
  363. fclose(fr);
  364.  
  365. start=cnt;
  366.  
  367. fs=fopen("start.txt","w");
  368. fprintf(fs,"%d",start);
  369. fclose(fs);
  370.  
  371.  
  372.  
  373. // for ticket printing loop
  374. cnt++;
  375.  
  376. fq=fopen("count.txt","w");
  377. fprintf(fq,"%d",cnt);
  378. fclose(fq);
  379.  
  380.  
  381.  
  382. strcpy(st[i].seat,"X");
  383.  
  384. printf("\n\n-------SEET HAS BEEN BOOKED-------\n\n");
  385. break;
  386. }
  387.  
  388.  
  389. }
  390.  
  391.  
  392.  
  393.  
  394. }
  395.  
  396. else
  397. {
  398.  
  399. fq=fopen("count.txt","r");
  400. fscanf(fq,"%d",&cnt);
  401. fclose(fq);
  402.  
  403.  
  404.  
  405. for(i=0;i<=39;i++)
  406. {
  407. c=strcmp(st[i].seat,seat_num);
  408. if(c==0)
  409. {
  410. strcpy(a[cnt].seat,st[i].seat);
  411.  
  412. fr=fopen("ticket.txt","a");
  413. fprintf(fr,"%s ",a[cnt].seat);
  414. fclose(fr);
  415.  
  416.  
  417. cnt++;
  418.  
  419. fq=fopen("count.txt","w");
  420. fprintf(fq,"%d",cnt);
  421. fclose(fq);
  422.  
  423.  
  424.  
  425. strcpy(st[i].seat,"X");
  426.  
  427. printf("\n\n-------SEET HAS BEEN BOOKED-------\n\n");
  428. break;
  429. }
  430.  
  431.  
  432. }
  433.  
  434.  
  435. }
  436.  
  437.  
  438.  
  439.  
  440.  
  441. fp=fopen("check.txt","w");
  442.  
  443. for(i=0;i<=39;i++)
  444. {
  445.  
  446. fprintf(fp,"%s ",st[l].seat);
  447.  
  448. l++;
  449.  
  450.  
  451. }
  452. fclose(fp);
  453.  
  454. printf("\n\n-----------CURRENTLY AVAILABLE SEAT-----------\n\n");
  455.  
  456. for(i=0;i<=39;i++)
  457. {
  458.  
  459.  
  460. printf("%s\t",st[i].seat);
  461.  
  462. if(i==3||i==7||i==11||i==15||i==19||i==23||i==27||i==31||i==35)
  463. {
  464. printf("\n\n");
  465. }
  466.  
  467. }
  468.  
  469.  
  470.  
  471. }
  472.  
  473.  
  474. }while(ext!=2);
  475.  
  476.  
  477.  
  478.  
  479.  
  480. printf("\n\n-----------CURRENTLY AVAILABLE SEAT-----------\n\n");
  481.  
  482. for(i=0;i<=39;i++)
  483. {
  484.  
  485.  
  486. printf("%s\t",st[i].seat);
  487.  
  488. if(i==3||i==7||i==11||i==15||i==19||i==23||i==27||i==31||i==35)
  489. {
  490. printf("\n\n");
  491. }
  492.  
  493. }
  494.  
  495.  
  496. //ticket printing.............................................
  497.  
  498. ft=fopen("end.txt","w");
  499. fprintf(ft,"%d",cnt);
  500. fclose(ft);
  501.  
  502. ft=fopen("end.txt","r");
  503. fscanf(ft,"%d",&end);
  504. fclose(ft);
  505.  
  506. fs=fopen("start.txt","r");
  507. fscanf(fs,"%d",&start);
  508. fclose(fs);
  509.  
  510. int key;
  511.  
  512. //for printing ticket loop
  513. do{
  514. printf("\n\nTO Print Ticket Press 1: ");
  515. scanf("%d",&key);
  516. printf("\n\n\n");
  517.  
  518.  
  519.  
  520.  
  521. if(key==1)
  522. {
  523. printf("\n\n*********************************FRIEND EXPRESS*****************************\n\n");
  524. printf("Bus Name: %s\t\t\t\tBus Time: %.2f am\n\n",data[0].bus_name,data[0].bus_time);
  525. printf("From: %s\t\t\t\tTO: %s\n\n",data[0].departure,data[0].destination);
  526. printf("Contact Num: 01768094971\t\tPrice: %.2f tk\n\n",(end-start)*500.0);
  527. printf("Seat Num: ");
  528.  
  529. for(i=start;i<end;i++)
  530. {
  531.  
  532. printf("%s ",a[i].seat);
  533. }
  534. printf("\n\n************************************Thank You*******************************\n\n");
  535.  
  536. }
  537.  
  538. else
  539. {
  540. printf("\nSorry Wrong Input.\n\n");
  541. }
  542.  
  543. } while(key!=1);
  544.  
  545.  
  546. fs=fopen("start.txt","w");
  547. fprintf(fs,"%d",cnt);
  548. fclose(fs);
  549.  
  550.  
  551.  
  552.  
  553. }
  554.  
  555.  
  556.  
  557.  
  558. //=========================================strat
  559.  
  560.  
  561.  
  562.  
  563. else if(strcmp(data[1].bus_name,ch)==0)
  564.  
  565.  
  566.  
  567. {
  568.  
  569. if(fa==NULL)
  570. {
  571.  
  572. printf("-------+++-----AVAILABLE SEAT------+++-----\n\n");
  573.  
  574. for(i=0;i<=39;i++)
  575. {
  576.  
  577.  
  578. printf("%s\t",st[i].seat);
  579.  
  580. if(i==3||i==7||i==11||i==15||i==19||i==23||i==27||i==31||i==35)
  581. {
  582. printf("\n\n");
  583. }
  584.  
  585.  
  586.  
  587.  
  588.  
  589. }
  590.  
  591. }
  592.  
  593. else
  594. {
  595. p=0;
  596. printf("---***----AVAILABLE SEAT----***---\n\n");
  597. fa=fopen("a.txt","r");
  598. for(i=0;i<=39;i++)
  599. {
  600.  
  601. fscanf(fa,"%s ",st[i].seat);
  602.  
  603. }
  604.  
  605. for(i=0;i<=39;i++)
  606. {
  607.  
  608.  
  609. printf("%s\t",st[i].seat);
  610.  
  611. if(i==3||i==7||i==11||i==15||i==19||i==23||i==27||i==31||i==35)
  612. {
  613. printf("\n\n");
  614. }
  615.  
  616. }
  617.  
  618.  
  619. fclose(fa);
  620. }
  621.  
  622.  
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629. do
  630. {
  631. p=0;
  632. l=0;
  633.  
  634.  
  635. printf("\n\nTo Book Seat Press-->>>:1\nTo Exit Press--->>>>>:2\n\n");
  636. printf("Pls Press------->>>>>:");
  637.  
  638. scanf("%d",&ext);
  639.  
  640. if(ext==1)
  641. {
  642.  
  643.  
  644. printf("\n\n-----------BOOK YOUR SEAT NOW--------------\n\n");
  645.  
  646. printf("Enter Seat Num:");
  647. scanf("%s",seat_num);
  648.  
  649.  
  650. fb=fopen("b.txt","r");
  651. fclose(fb);
  652.  
  653.  
  654. if(fb==NULL)
  655. {
  656. for(i=0;i<=39;i++)
  657. {
  658. c=strcmp(st[i].seat,seat_num);
  659. if(c==0)
  660. {
  661. strcpy(a[cnt].seat,st[i].seat);
  662.  
  663. fc=fopen("c.txt","w");
  664. fprintf(fc,"%s ",st[i].seat);
  665. fclose(fc);
  666.  
  667. start=cnt;
  668.  
  669. fd=fopen("d.txt","w");
  670. fprintf(fd,"%d",start);
  671. fclose(fd);
  672.  
  673.  
  674.  
  675. // for ticket printing loop
  676. cnt++;
  677.  
  678. fb=fopen("b.txt","w");
  679. fprintf(fb,"%d",cnt);
  680. fclose(fb);
  681.  
  682.  
  683.  
  684. strcpy(st[i].seat,"X");
  685.  
  686. printf("\n\n-------SEET HAS BEEN BOOKED-------\n\n");
  687. break;
  688. }
  689.  
  690.  
  691. }
  692.  
  693.  
  694.  
  695.  
  696. }
  697.  
  698. else
  699. {
  700.  
  701. fb=fopen("b.txt","r");
  702. fscanf(fb,"%d",&cnt);
  703. fclose(fb);
  704.  
  705.  
  706.  
  707. for(i=0;i<=39;i++)
  708. {
  709. c=strcmp(st[i].seat,seat_num);
  710. if(c==0)
  711. {
  712. strcpy(a[cnt].seat,st[i].seat);
  713.  
  714. fc=fopen("c.txt","a");
  715. fprintf(fc,"%s ",a[cnt].seat);
  716. fclose(fc);
  717.  
  718.  
  719. cnt++;
  720.  
  721. fb=fopen("b.txt","w");
  722. fprintf(fb,"%d",cnt);
  723. fclose(fb);
  724.  
  725.  
  726.  
  727. strcpy(st[i].seat,"X");
  728.  
  729. printf("\n\n-------SEET HAS BEEN BOOKED-------\n\n");
  730. break;
  731. }
  732.  
  733.  
  734. }
  735.  
  736.  
  737. }
  738.  
  739.  
  740.  
  741.  
  742.  
  743. fa=fopen("a.txt","w");
  744.  
  745. for(i=0;i<=39;i++)
  746. {
  747.  
  748. fprintf(fa,"%s ",st[l].seat);
  749.  
  750. l++;
  751.  
  752.  
  753. }
  754. fclose(fa);
  755.  
  756. printf("\n\n-----------CURRENTLY AVAILABLE SEAT-----------\n\n");
  757.  
  758. for(i=0;i<=39;i++)
  759. {
  760.  
  761.  
  762. printf("%s\t",st[i].seat);
  763.  
  764. if(i==3||i==7||i==11||i==15||i==19||i==23||i==27||i==31||i==35)
  765. {
  766. printf("\n\n");
  767. }
  768.  
  769. }
  770.  
  771.  
  772.  
  773. }
  774.  
  775.  
  776. }while(ext!=2);
  777.  
  778.  
  779.  
  780.  
  781.  
  782. printf("\n\n-----------CURRENTLY AVAILABLE SEAT-----------\n\n");
  783.  
  784. for(i=0;i<=39;i++)
  785. {
  786.  
  787.  
  788. printf("%s\t",st[i].seat);
  789.  
  790. if(i==3||i==7||i==11||i==15||i==19||i==23||i==27||i==31||i==35)
  791. {
  792. printf("\n\n");
  793. }
  794.  
  795. }
  796.  
  797.  
  798. //ticket printing.............................................
  799.  
  800. fe=fopen("e.txt","w");
  801. fprintf(fe,"%d",cnt);
  802. fclose(fe);
  803.  
  804. fe=fopen("e.txt","r");
  805. fscanf(fe,"%d",&end);
  806. fclose(fe);
  807.  
  808. fd=fopen("d.txt","r");
  809. fscanf(fd,"%d",&start);
  810. fclose(fd);
  811.  
  812. int key;
  813.  
  814. //for printing ticket loop
  815. do{
  816. printf("\n\nTO Print Ticket Press 1: ");
  817. scanf("%d",&key);
  818. printf("\n\n\n");
  819.  
  820.  
  821.  
  822.  
  823. if(key==1)
  824. {
  825. printf("\n\n*********************************FRIEND EXPRESS*****************************\n\n");
  826. printf("Bus Name: %s\t\t\t\tBus Time: %.2f am\n\n",data[1].bus_name,data[1].bus_time);
  827. printf("From: %s\t\t\t\tTO: %s\n\n",data[1].departure,data[1].destination);
  828. printf("Contact Num: 01768094971\t\tPrice: %.2f tk\n\n",(end-start)*800.0);
  829. printf("Seat Num: ");
  830.  
  831. for(i=start;i<end;i++)
  832. {
  833.  
  834. printf("%s ",a[i].seat);
  835. }
  836. printf("\n\n************************************Thank You*******************************\n\n");
  837.  
  838. }
  839.  
  840. else
  841. {
  842. printf("\nSorry Wrong Input.\n\n");
  843. }
  844.  
  845. } while(key!=1);
  846.  
  847.  
  848. fd=fopen("d.txt","w");
  849. fprintf(fd,"%d",cnt);
  850. fclose(fd);
  851.  
  852.  
  853.  
  854.  
  855. }
  856.  
  857.  
  858.  
  859. //==========================================end
  860.  
  861. //===========================start 2
  862.  
  863.  
  864. else if(strcmp(data[2].bus_name,ch)==0)
  865.  
  866.  
  867.  
  868. {
  869.  
  870. if(ff==NULL)
  871. {
  872.  
  873. printf("-------+++-----AVAILABLE SEAT------+++-----\n\n");
  874.  
  875. for(i=0;i<=39;i++)
  876. {
  877.  
  878.  
  879. printf("%s\t",st[i].seat);
  880.  
  881. if(i==3||i==7||i==11||i==15||i==19||i==23||i==27||i==31||i==35)
  882. {
  883. printf("\n\n");
  884. }
  885.  
  886.  
  887.  
  888.  
  889.  
  890. }
  891.  
  892. }
  893.  
  894. else
  895. {
  896. p=0;
  897. printf("---***----AVAILABLE SEAT----***---\n\n");
  898. ff=fopen("f.txt","r");
  899. for(i=0;i<=39;i++)
  900. {
  901.  
  902. fscanf(ff,"%s ",st[i].seat);
  903.  
  904. }
  905.  
  906. for(i=0;i<=39;i++)
  907. {
  908.  
  909.  
  910. printf("%s\t",st[i].seat);
  911.  
  912. if(i==3||i==7||i==11||i==15||i==19||i==23||i==27||i==31||i==35)
  913. {
  914. printf("\n\n");
  915. }
  916.  
  917. }
  918.  
  919.  
  920. fclose(ff);
  921. }
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930. do
  931. {
  932. p=0;
  933. l=0;
  934.  
  935.  
  936. printf("\n\nTo Book Seat Press-->>>:1\nTo Exit Press--->>>>>:2\n\n");
  937. printf("Pls Press------->>>>>:");
  938.  
  939. scanf("%d",&ext);
  940.  
  941. if(ext==1)
  942. {
  943.  
  944.  
  945. printf("\n\n-----------BOOK YOUR SEAT NOW--------------\n\n");
  946.  
  947. printf("Enter Seat Num:");
  948. scanf("%s",seat_num);
  949.  
  950.  
  951. fg=fopen("g.txt","r");
  952. fclose(fg);
  953.  
  954.  
  955. if(fg==NULL)
  956. {
  957. for(i=0;i<=39;i++)
  958. {
  959. c=strcmp(st[i].seat,seat_num);
  960. if(c==0)
  961. {
  962. strcpy(a[cnt].seat,st[i].seat);
  963.  
  964. fh=fopen("h.txt","w");
  965. fprintf(fh,"%s ",st[i].seat);
  966. fclose(fh);
  967.  
  968. start=cnt;
  969.  
  970. fi=fopen("i.txt","w");
  971. fprintf(fi,"%d",start);
  972. fclose(fi);
  973.  
  974.  
  975.  
  976. // for ticket printing loop
  977. cnt++;
  978.  
  979. fg=fopen("g.txt","w");
  980. fprintf(fg,"%d",cnt);
  981. fclose(fg);
  982.  
  983.  
  984.  
  985. strcpy(st[i].seat,"X");
  986.  
  987. printf("\n\n-------SEET HAS BEEN BOOKED-------\n\n");
  988. break;
  989. }
  990.  
  991.  
  992. }
  993.  
  994.  
  995.  
  996.  
  997. }
  998.  
  999. else
  1000. {
  1001.  
  1002. fg=fopen("g.txt","r");
  1003. fscanf(fg,"%d",&cnt);
  1004. fclose(fg);
  1005.  
  1006.  
  1007.  
  1008. for(i=0;i<=39;i++)
  1009. {
  1010. c=strcmp(st[i].seat,seat_num);
  1011. if(c==0)
  1012. {
  1013. strcpy(a[cnt].seat,st[i].seat);
  1014.  
  1015. fh=fopen("h.txt","a");
  1016. fprintf(fh,"%s ",a[cnt].seat);
  1017. fclose(fh);
  1018.  
  1019.  
  1020. cnt++;
  1021.  
  1022. fg=fopen("g.txt","w");
  1023. fprintf(fg,"%d",cnt);
  1024. fclose(fg);
  1025.  
  1026.  
  1027.  
  1028. strcpy(st[i].seat,"X");
  1029.  
  1030. printf("\n\n-------SEET HAS BEEN BOOKED-------\n\n");
  1031. break;
  1032. }
  1033.  
  1034.  
  1035. }
  1036.  
  1037.  
  1038. }
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044. ff=fopen("f.txt","w");
  1045.  
  1046. for(i=0;i<=39;i++)
  1047. {
  1048.  
  1049. fprintf(ff,"%s ",st[l].seat);
  1050.  
  1051. l++;
  1052.  
  1053.  
  1054. }
  1055. fclose(ff);
  1056.  
  1057. printf("\n\n-----------CURRENTLY AVAILABLE SEAT-----------\n\n");
  1058.  
  1059. for(i=0;i<=39;i++)
  1060. {
  1061.  
  1062.  
  1063. printf("%s\t",st[i].seat);
  1064.  
  1065. if(i==3||i==7||i==11||i==15||i==19||i==23||i==27||i==31||i==35)
  1066. {
  1067. printf("\n\n");
  1068. }
  1069.  
  1070. }
  1071.  
  1072.  
  1073.  
  1074. }
  1075.  
  1076.  
  1077. }while(ext!=2);
  1078.  
  1079.  
  1080.  
  1081.  
  1082.  
  1083. printf("\n\n-----------CURRENTLY AVAILABLE SEAT-----------\n\n");
  1084.  
  1085. for(i=0;i<=39;i++)
  1086. {
  1087.  
  1088.  
  1089. printf("%s\t",st[i].seat);
  1090.  
  1091. if(i==3||i==7||i==11||i==15||i==19||i==23||i==27||i==31||i==35)
  1092. {
  1093. printf("\n\n");
  1094. }
  1095.  
  1096. }
  1097.  
  1098.  
  1099. //ticket printing.............................................
  1100.  
  1101. fj=fopen("j.txt","w");
  1102. fprintf(fj,"%d",cnt);
  1103. fclose(fj);
  1104.  
  1105. fj=fopen("j.txt","r");
  1106. fscanf(fj,"%d",&end);
  1107. fclose(fj);
  1108.  
  1109. fi=fopen("i.txt","r");
  1110. fscanf(fi,"%d",&start);
  1111. fclose(fi);
  1112.  
  1113. int key;
  1114.  
  1115. //for printing ticket loop
  1116. do{
  1117. printf("\n\nTO Print Ticket Press 1: ");
  1118. scanf("%d",&key);
  1119. printf("\n\n\n");
  1120.  
  1121.  
  1122.  
  1123.  
  1124. if(key==1)
  1125. {
  1126. printf("\n\n*********************************FRIEND EXPRESS*****************************\n\n");
  1127. printf("Bus Name: %s\t\t\t\tBus Time: %.2f am\n\n","fe-3",data[2].bus_time);
  1128. printf("From: %s\t\t\t\tTO: %s\n\n",data[2].departure,data[2].destination);
  1129. printf("Contact Num: 01768094971\t\tPrice: %.2f tk\n\n",(end-start)*1000.0);
  1130. printf("Seat Num: ");
  1131.  
  1132. for(i=start;i<end;i++)
  1133. {
  1134.  
  1135. printf("%s ",a[i].seat);
  1136. }
  1137. printf("\n\n************************************Thank You*******************************\n\n");
  1138.  
  1139. }
  1140.  
  1141. else
  1142. {
  1143. printf("\nSorry Wrong Input.\n\n");
  1144. }
  1145.  
  1146. } while(key!=1);
  1147.  
  1148.  
  1149. fi=fopen("i.txt","w");
  1150. fprintf(fi,"%d",cnt);
  1151. fclose(fi);
  1152.  
  1153.  
  1154.  
  1155.  
  1156. }
  1157.  
  1158.  
  1159.  
  1160. // ==========================end 2
  1161. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement