Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.48 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <math.h>
  5.  
  6. struct dates
  7. {
  8. int dateloopd,dayd,monthd;
  9. };
  10.  
  11. struct receipts
  12. {
  13. int start,desti,seating,arrivaltime,dayr,monthr,train,time;
  14. float fee;
  15. };
  16.  
  17. int menu(void);
  18. int startf();
  19. int destif(int start);
  20. int confirmation(int start, int desti);
  21. struct dates datef();
  22. int timef();
  23. int trainf();
  24. int seatingf();
  25. int agediscountf();
  26. int discountf();
  27. int timecf(int start, int desti, int time, int traintype);
  28. float feef(int start, int desti,int seattype, int traintype, float agediscmod, float discmod, struct dates display);
  29. void receiptf(int start, int desti, struct dates display, int time, int train, int seating, int arrivaltime, float fee);
  30. void receiptoutf(struct receipts receiptout);
  31.  
  32. int main()
  33. {
  34. int menuloop=0, start,desti,startloop,destiloop,dateloop,date,timeloop,time,trainloop,train,traintype,discloop,agediscloop,agedisc,seating,seatloop,seattype,discount,receiptloop,confirm;
  35. int arrivaltime;
  36. float agediscmod,discmod,fee;
  37. struct dates display;
  38. struct receipts receiptout;
  39.  
  40. do
  41. {
  42. menuloop = menu();
  43.  
  44. switch (menuloop)
  45. {
  46. case 1:
  47. startloop = 1;
  48. break;
  49. default:
  50. startloop = 0;
  51. break;
  52. }
  53.  
  54. while (startloop == 1)
  55. {
  56. start = startf();
  57.  
  58. switch (start)
  59. {
  60. case 1: case 2: case 3:
  61. destiloop = 1;
  62. break;
  63. case 0:
  64. startloop = 0;
  65. destiloop = 0;
  66. break;
  67. default:
  68. destiloop = 0;
  69. break;
  70. }
  71.  
  72. while (destiloop == 1)
  73. {
  74. desti = destif(start);
  75.  
  76. switch (desti)
  77. {
  78. case 1: case 2: case 3:
  79. confirm = confirmation(start,desti);
  80. break;
  81. case 9 :
  82. confirm = 2;
  83. break;
  84. default:
  85. confirm = 2;
  86. break;
  87. }
  88.  
  89. switch (confirm)
  90. {
  91. case 1:
  92. dateloop = 1;
  93. destiloop = 0;
  94. break;
  95. case 2:
  96. dateloop = 0;
  97. destiloop = 0;
  98. startloop = 1;
  99. break;
  100. case 3:
  101. dateloop = 0;
  102. destiloop = 1;
  103. break;
  104. default:
  105. destiloop = 1;
  106. dateloop = 0;
  107. break;
  108. }
  109.  
  110.  
  111.  
  112. while (dateloop == 1)
  113. {
  114. display = datef();
  115. date = display.dateloopd;
  116.  
  117. switch (date)
  118. {
  119. case 1:
  120. dateloop = 0;
  121. timeloop = 1;
  122. break;
  123. case 0:
  124. dateloop = 1;
  125. timeloop = 0;
  126. break;
  127. default:
  128. dateloop = 1;
  129. timeloop = 0;
  130. break;
  131. }
  132.  
  133. while (timeloop == 1)
  134. {
  135. system("CLS");
  136. time = timef();
  137.  
  138. switch (time)
  139. {
  140. case 1000:
  141. timeloop = 0;
  142. trainloop = 1;
  143. break;
  144. case 1200:
  145. timeloop = 0;
  146. trainloop = 1;
  147. break;
  148. case 9:
  149. dateloop = 1;
  150. timeloop = 0;
  151. trainloop = 0;
  152. break;
  153. default:
  154. timeloop = 1;
  155. trainloop = 0;
  156. break;
  157. }
  158.  
  159. while (trainloop == 1)
  160. {
  161. train = trainf();
  162.  
  163. switch (train)
  164. {
  165. case 1:
  166. traintype = 1;
  167. trainloop = 0;
  168. seatloop = 1;
  169. break;
  170. case 2:
  171. traintype = 2;
  172. trainloop = 0;
  173. seatloop = 1;
  174. break;
  175. case 3:
  176. traintype = 3;
  177. trainloop = 0;
  178. seatloop = 1;
  179. break;
  180. case 9:
  181. timeloop = 1;
  182. trainloop = 0;
  183. seatloop = 0;
  184. break;
  185. default:
  186. trainloop = 1;
  187. seatloop = 0;
  188. break;
  189. }
  190.  
  191. while (seatloop == 1)
  192. {
  193. seating = seatingf();
  194.  
  195. switch (seating)
  196. {
  197. case 1:
  198. seattype = 1;
  199. agediscloop = 1;
  200. seatloop = 0;
  201. break;
  202. case 2:
  203. seattype = 2;
  204. agediscloop = 1;
  205. seatloop = 0;
  206. break;
  207. case 9:
  208. trainloop = 1;
  209. seatloop = 0;
  210. agediscloop = 0;
  211. break;
  212. default:
  213. trainloop = 0;
  214. seatloop = 1;
  215. agediscloop = 0;
  216. break;
  217. }
  218.  
  219. while (agediscloop == 1)
  220. {
  221. agedisc = agediscountf();
  222.  
  223. switch (agedisc)
  224. {
  225. case 1: case 3:
  226. agediscmod = 0.5;
  227. agediscloop = 0;
  228. discloop = 1;
  229. break;
  230. case 2:
  231. agediscmod = 1.0;
  232. agediscloop = 0;
  233. discloop = 1;
  234. break;
  235. case 0:
  236. seatloop = 1;
  237. agediscloop = 0;
  238. discloop = 0;
  239. break;
  240. default:
  241. agediscloop = 1;
  242. discloop = 0;
  243. break;
  244. }
  245.  
  246. while (discloop == 1)
  247. {
  248. discount = discountf();
  249.  
  250. switch (discount)
  251. {
  252. case 0:
  253. discmod = 1.0;
  254. receiptloop = 1;
  255. discloop = 0;
  256. break;
  257. case 1:
  258. discmod = 0;
  259. receiptloop = 1;
  260. discloop = 0;
  261. break;
  262. case 2:
  263. discmod = 0.75;
  264. receiptloop = 1;
  265. discloop = 0;
  266. break;
  267. default:
  268. receiptloop = 0;
  269. discloop = 1;
  270. break;
  271. }
  272.  
  273. while (receiptloop == 1)
  274. {
  275. arrivaltime = timecf(start, desti, time, traintype);
  276. fee = feef(start, desti, seattype, traintype, agediscmod, discmod, display);
  277.  
  278. receiptf(start, desti, display, time, train, seating, arrivaltime, fee);
  279.  
  280. receiptout.arrivaltime = arrivaltime;
  281. receiptout.dayr = display.dayd;
  282. receiptout.desti = desti;
  283. receiptout.fee = fee;
  284. receiptout.monthr = display.monthd;
  285. receiptout.seating = seating;
  286. receiptout.start = start;
  287. receiptout.train = train;
  288. receiptout.time = time;
  289. receiptout.fee = fee;
  290.  
  291. receiptoutf(receiptout);
  292.  
  293. system("PAUSE");
  294. receiptloop = 0;
  295. discloop = 0;
  296. agediscloop = 0;
  297. seatloop = 0;
  298. trainloop = 0;
  299. timeloop = 0;
  300. dateloop = 0;
  301. destiloop = 0;
  302. startloop = 0;
  303. menuloop = 1;
  304. }
  305. }
  306. }
  307. }
  308. }
  309. }
  310. }
  311. }
  312. }
  313. } while (menuloop != 0);
  314. return 0;
  315. }
  316.  
  317. int menu()
  318. {
  319. char menuinput[30];
  320. int loop;
  321.  
  322. system("CLS");
  323. printf("\t+=================================================================+\n");
  324. printf("\t| |\n");
  325. printf("\t| Tokaido Shinkansen Ticket Reservation System |\n");
  326. printf("\t| |\n");
  327. printf("\t+=================================================================+\n");
  328. printf("\n\t\t1. Reserve Tickets\n");
  329. printf("\t\t9. Exit\n\n");
  330. printf("\n\n\n\n>> ");
  331. fflush(stdin);
  332. gets_s(menuinput);
  333.  
  334. if (_strcmpi(menuinput,"1") == 0)
  335. {
  336. loop = 1;
  337. }
  338. else
  339. {
  340. if (_strcmpi(menuinput,"2") == 0)
  341. {
  342. loop = 2;
  343. }
  344. else
  345. {
  346. if (_strcmpi(menuinput,"9") == 0)
  347. {
  348. loop = 0;
  349. }
  350. else
  351. {
  352. loop = 9;
  353. }
  354. }
  355. }
  356. return loop;
  357. }
  358.  
  359. int startf()
  360. {
  361. char startinput[30];
  362. int loop;
  363.  
  364. system("CLS");
  365. printf("\n\t\t\t Starting station");
  366. printf("\n\n\n\n\t Tokyo(1) Nagoya(2) Shin-Osaka(3)");
  367. printf("\n | | |");
  368. printf("\n ===========+====================+=====================================+=======");
  369. printf("\n\n\t\t\t Type 9 to return to main menu.");
  370. printf("\n\n\n\n>> ");
  371. fflush(stdin);
  372. gets_s(startinput);
  373.  
  374. if (_strcmpi(startinput,"Tokyo") == 0)
  375. {
  376. loop = 1;
  377. }
  378. else
  379. {
  380. if (_strcmpi(startinput,"1") == 0)
  381. {
  382. loop = 1;
  383. }
  384. else
  385. {
  386. if (_strcmpi(startinput,"Nagoya") == 0)
  387. {
  388. loop = 2;
  389. }
  390. else
  391. {
  392. if(_strcmpi(startinput,"2") == 0)
  393. {
  394. loop = 2;
  395. }
  396. else
  397. {
  398. if (_strcmpi(startinput,"Shin-Osaka") == 0)
  399. {
  400. loop = 3;
  401. }
  402. else
  403. {
  404. if (_strcmpi(startinput,"3") == 0)
  405. {
  406. loop = 3;
  407. }
  408. else
  409. {
  410. if (_strcmpi(startinput,"9") == 0)
  411. {
  412. loop = 0;
  413. }
  414. else
  415. {
  416. loop = 9;
  417. }
  418. }
  419. }
  420. }
  421. }
  422. }
  423. }
  424.  
  425. return loop;
  426. }
  427.  
  428. int destif (int start)
  429. {
  430. int desti;
  431. char destination[30];
  432.  
  433. switch (start)
  434. {
  435. case 1:
  436. system("CLS");
  437. printf("\n\t\t\t Destination");
  438. printf("\n\n\n\n\t Nagoya(2) Shin-Osaka(3)");
  439. printf("\n | |");
  440. printf("\n ================================+=====================================+=======");
  441. printf("\n\n\t\tType 9 to return to starting station selection.");
  442. printf("\n\n\n\n>> ");
  443. fflush(stdin);
  444. gets_s(destination);
  445.  
  446. if (_strcmpi(destination,"nagoya") == 0)
  447. {
  448. desti = 2;
  449. }
  450. else
  451. {
  452. if (_strcmpi(destination,"2") == 0)
  453. {
  454. desti = 2;
  455. }
  456. else
  457. {
  458. if (_strcmpi(destination,"shin-osaka") == 0)
  459. {
  460. desti = 3;
  461. }
  462. else
  463. {
  464. if (_strcmpi(destination,"3") == 0)
  465. {
  466. desti = 3;
  467. }
  468. else
  469. {
  470. if (_strcmpi(destination,"9") == 0)
  471. {
  472. desti = 9;
  473. }
  474. else
  475. {
  476. desti = 4;
  477. }
  478. }
  479. }
  480. }
  481. }
  482.  
  483. break;
  484. case 2:
  485. system("CLS");
  486. printf("\n\t\t\t Destination");
  487. printf("\n\n\n\n\t Tokyo(1) Shin-Osaka(3)");
  488. printf("\n | |");
  489. printf("\n ===========+==========================================================+=======");
  490. printf("\n\n\t\tType 9 to return to starting station selection.");
  491. printf("\n\n\n\n>> ");
  492. fflush(stdin);
  493. gets_s(destination);
  494.  
  495. if (_strcmpi(destination,"tokyo") == 0)
  496. {
  497. desti = 1;
  498. }
  499. else
  500. {
  501. if (_strcmpi(destination,"1") == 0)
  502. {
  503. desti = 1;
  504. }
  505. else
  506. {
  507. if (_strcmpi(destination,"shin-osaka") == 0)
  508. {
  509. desti = 3;
  510. }
  511. else
  512. {
  513. if (_strcmpi(destination,"3") == 0)
  514. {
  515. desti = 3;
  516. }
  517. else
  518. {
  519. if (_strcmpi(destination,"9") == 0)
  520. {
  521. desti = 9;
  522. }
  523. else
  524. {
  525. desti = 9;
  526. }
  527. }
  528. }
  529. }
  530. }
  531.  
  532. break;
  533. case 3:
  534. system("CLS");
  535. printf("\n\t\t\t Destination");
  536. printf("\n\n\n\n\t Tokyo(1) Nagoya(2)");
  537. printf("\n | |");
  538. printf("\n ===========+====================+=============================================");
  539. printf("\n\n\t\tType 9 to return to starting station selection.");
  540. printf("\n\n\n\n>> ");
  541. fflush(stdin);
  542. gets_s(destination);
  543.  
  544. if (_strcmpi(destination,"tokyo") == 0)
  545. {
  546. desti = 1;
  547. }
  548. else
  549. {
  550. if (_strcmpi(destination,"1") == 0)
  551. {
  552. desti = 1;
  553. }
  554. else
  555. {
  556. if (_strcmpi(destination,"nagoya") == 0)
  557. {
  558. desti = 2;
  559. }
  560. else
  561. {
  562. if (_strcmpi(destination,"2") == 0)
  563. {
  564. desti = 2;
  565. }
  566. else
  567. {
  568. if (_strcmpi(destination,"9") == 0)
  569. {
  570. desti = 9;
  571. }
  572. else
  573. {
  574. desti = 9;
  575. }
  576. }
  577. }
  578. }
  579. }
  580.  
  581. break;
  582. }
  583.  
  584. return desti;
  585. }
  586.  
  587. int confirmation(int start, int desti)
  588. {
  589. char input[500];
  590. int inputi, confirm,confirmloop=1;
  591.  
  592. while (confirmloop == 1)
  593. {
  594. system("CLS");
  595. printf("\n\t\t\tConfirmation Screen\n");
  596.  
  597. switch (start)
  598. {
  599. case 1:
  600. printf("\nStarting Station: Tokyo\n");
  601. break;
  602. case 2:
  603. printf("\nStarting Station: Nagoya\n");
  604. break;
  605. case 3:
  606. printf("\nStarting Station: Shin-Osaka\n");
  607. break;
  608. }
  609.  
  610. switch (desti)
  611. {
  612. case 1:
  613. printf("\nDestination: Tokyo\n");
  614. break;
  615. case 2:
  616. printf("\nDestination: Nagoya\n");
  617. break;
  618. case 3:
  619. printf("\nDestination: Shin-Osaka\n");
  620. break;
  621. }
  622.  
  623. printf("\nEnter 1 to confirm starting station and destination");
  624. printf("\nEnter 2 to choose starting station");
  625. printf("\nEnter 3 to choose destination");
  626. printf("\n\n\n\n>>");
  627. gets(input);
  628.  
  629. inputi = atoi(input);
  630.  
  631. switch (inputi)
  632. {
  633. case 1:
  634. confirm = 1;
  635. confirmloop = 0;
  636. break;
  637. case 2:
  638. confirm = 2;
  639. confirmloop = 0;
  640. break;
  641. case 3:
  642. confirm = 3;
  643. confirmloop = 0;
  644. break;
  645. default:
  646. confirmloop = 1;
  647. break;
  648. }
  649. }
  650.  
  651. return confirm;
  652. }
  653.  
  654. struct dates datef()
  655. {
  656. int month,loop,daysetting,day,dayloop;
  657. struct dates display;
  658. char dayf[500],monthf[500];
  659.  
  660. system("CLS");
  661. printf("\n\t\t\tDate of departure\n");
  662. printf("\nMonth List: January(1) February(2) March(3) April(4) May(5) June(6) July(7)\n\t August(8) September(9) October(10) November(11) December(12)\n");
  663. printf("\n\n\n\n\n\n\n\nEnter month: ");
  664. fflush(stdin);
  665. gets_s(monthf);
  666.  
  667. month = atoi(monthf);
  668.  
  669. switch (month)
  670. {
  671. case 1: case 3: case 5: case 7: case 8: case 10: case 12:
  672. daysetting = 1;
  673. dayloop = 1;
  674. break;
  675. case 2:
  676. daysetting = 2;
  677. dayloop = 1;
  678. break;
  679. case 4: case 6: case 9: case 11:
  680. daysetting = 3;
  681. dayloop = 1;
  682. break;
  683. default:
  684. daysetting = 0;
  685. break;
  686. }
  687.  
  688. if (daysetting == 1)
  689. {
  690. while (dayloop == 1)
  691. {
  692. system("CLS");
  693. printf("\n\t\t\tDate of departure\n");
  694. printf("\nList of days: 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\n");
  695. printf("\t 26 27 28 29 30 31\n");
  696. printf("\n\t Type 0 to return to month selection.\n");
  697. printf("\n\n\n\n\n\n\nEnter day: ");
  698. fflush(stdin);
  699. gets_s(dayf);
  700.  
  701. day = atoi(dayf);
  702.  
  703. if (day == 0)
  704. {
  705. dayloop = 0;
  706. daysetting = 0;
  707. }
  708. else
  709. {
  710. if (day < 0)
  711. {
  712. printf("Invalid day.");
  713. system("PAUSE");
  714. }
  715. else
  716. {
  717. if (day > 31)
  718. {
  719. printf("Invalid day.");
  720. system("PAUSE");
  721. }
  722. else
  723. {
  724. dayloop = 0;
  725. loop = 1;
  726. }
  727. }
  728. }
  729. }
  730. }
  731. else
  732. {
  733. if (daysetting == 2)
  734. {
  735. while (dayloop == 1)
  736. {
  737. system("CLS");
  738. printf("\n\t\t\tDate of departure\n");
  739. printf("\nList of days: 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\n");
  740. printf("\t 26 27 28\n");
  741. printf("\n\t Type 0 to return to month selection.\n");
  742. printf("\n\n\n\n\n\n\nEnter day: ");
  743. fflush(stdin);
  744. scanf_s("%d",&day);
  745.  
  746. if (day == 0)
  747. {
  748. dayloop = 0;
  749. daysetting = 0;
  750. }
  751. else
  752. {
  753. if (day < 0)
  754. {
  755. printf("Invalid day.");
  756. system("PAUSE");
  757. }
  758. else
  759. {
  760. if (day > 28)
  761. {
  762. printf("Invalid day.");
  763. system("PAUSE");
  764. }
  765. else
  766. {
  767. dayloop = 0;
  768. loop = 1;
  769. }
  770. }
  771. }
  772. }
  773. }
  774. else
  775. {
  776. if (daysetting == 3)
  777. {
  778. while (dayloop == 1)
  779. {
  780. system("CLS");
  781. printf("\n\t\t\tDate of departure\n");
  782. printf("\nList of days: 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\n");
  783. printf("\t 26 27 28 29 30\n");
  784. printf("\n\t Type 0 to return to month selection.\n");
  785. printf("\n\n\n\n\n\n\nEnter day: ");
  786. scanf_s("%d",&day);
  787.  
  788. if (day == 0)
  789. {
  790. dayloop = 0;
  791. daysetting = 0;
  792. }
  793. else
  794. {
  795. if (day < 0)
  796. {
  797. printf("Invalid day.");
  798. system("PAUSE");
  799. }
  800. else
  801. {
  802. if (day > 30)
  803. {
  804. printf("Invalid day.");
  805. system("PAUSE");
  806. }
  807. else
  808. {
  809. dayloop = 0;
  810. loop = 1;
  811. }
  812. }
  813. }
  814. }
  815. }
  816. }
  817. }
  818.  
  819. display.monthd = month;
  820. display.dayd = day;
  821. display.dateloopd = loop;
  822.  
  823. return display;
  824. }
  825.  
  826. int timef()
  827. {
  828. char input[400];
  829. int inputi,loop;
  830.  
  831. system("CLS");
  832. printf("\n\t\t\t Departure Time");
  833. printf("\n\n1. 1000");
  834. printf("\n2. 1200");
  835. printf("\n\n\t\tType 9 to return to date selection.");
  836. printf("\n\n\n\n\n\n\n>> ");
  837. fflush(stdin);
  838. gets_s(input);
  839.  
  840. inputi = atoi(input);
  841.  
  842. switch (inputi)
  843. {
  844. case 1:
  845. loop = 1000;
  846. break;
  847. case 2:
  848. loop = 1200;
  849. break;
  850. case 9:
  851. loop = 9;
  852. break;
  853. default:
  854. loop = 1;
  855. break;
  856. }
  857.  
  858. return loop;
  859. }
  860.  
  861. int trainf()
  862. {
  863. char input[500];
  864. int inputi;
  865.  
  866. system("CLS");
  867. printf("\n\t\t\t Type of train");
  868. printf("\n\n1. Nozomi");
  869. printf("\n2. Hikari");
  870. printf("\n3. Kodama");
  871. printf("\n\n\t\t Type 9 to return to time selection.\n");
  872. printf("\n\n\n\n\n>> ");
  873. fflush(stdin);
  874. gets_s(input);
  875.  
  876. inputi = atoi(input);
  877.  
  878. return inputi;
  879. }
  880.  
  881. int seatingf()
  882. {
  883. char input[500];
  884. int inputi;
  885.  
  886. system("CLS");
  887. printf("\n\t\t\tType of seating\n");
  888. printf("\n1. First-class\n");
  889. printf("2. Economy\n");
  890. printf("\n\t\tType 9 to return to train selection\n");
  891. printf("\n\n\n\n\n\n>>");
  892. fflush(stdin);
  893. gets_s(input);
  894.  
  895. inputi = atoi(input);
  896.  
  897. return inputi;
  898. }
  899.  
  900. int agediscountf()
  901. {
  902. char input[400];
  903. int inputi,age,loop=1;
  904.  
  905. while (loop == 1)
  906. {
  907. system ("CLS");
  908. printf("\n\t\t\tAge\n");
  909. printf("\nSenior Citizens (60+): Half Price\n");
  910. printf("\nAdults: Full Price\n");
  911. printf("\nChildren (<12): Half Price\n");
  912. printf("\nType 0 to return to seating selection.\n");
  913. printf("\n\n\nEnter age: ");
  914. fflush(stdin);
  915. gets_s(input);
  916.  
  917. inputi = atoi(input);
  918.  
  919. if (inputi < 0)
  920. {
  921. system("CLS");
  922. printf("\n\n\n\n\t\t\t\tInvalid Age");
  923. system("PAUSE");
  924. loop = 1;
  925. }
  926. else
  927. {
  928. if (inputi == 0)
  929. {
  930. age = 0;
  931. loop = 0;
  932. }
  933. else
  934. {
  935. if (inputi > 12)
  936. {
  937. if (inputi > 60)
  938. {
  939. if (inputi > 150)
  940. {
  941. system("CLS");
  942. printf("\n\n\n\n\t\t\t\tInvalid Age");
  943. system("PAUSE");
  944. loop = 1;
  945. }
  946. else
  947. {
  948. age = 3;
  949. loop = 0;
  950. }
  951. }
  952. else
  953. {
  954. age = 2;
  955. loop = 0;
  956. }
  957. }
  958. else
  959. {
  960. age = 1;
  961. loop = 0;
  962. }
  963. }
  964. }
  965. }
  966.  
  967. return age;
  968. }
  969.  
  970. int discountf()
  971. {
  972. char input[500];
  973. float discountmod;
  974.  
  975. system("CLS");
  976. printf("\n\t\t\t Discount\n");
  977. printf("\n\n\nEnter code here (Type 0 if there is no code): ");
  978. fflush(stdin);
  979. gets_s(input);
  980.  
  981. if (_strcmpi(input,"kelvinstop") == 0)
  982. {
  983. printf("The ride is free.");
  984. system("PAUSE");
  985. }
  986. else
  987. {
  988. if (_strcmpi(input,"0") == 0)
  989. {
  990. discountmod = 0;
  991. }
  992. else
  993. {
  994. if (_strcmpi(input,"kelvindont") == 0)
  995. {
  996. discountmod = 0;
  997. }
  998. else
  999. {
  1000. if (_strcmpi(input,"hhgqnnhb3y") == 0)
  1001. {
  1002. discountmod = 2;
  1003. }
  1004. else
  1005. {
  1006. system("CLS");
  1007. printf("\n\n\n\n\t\t\tInvalid Code.\n\n");
  1008. system("PAUSE");
  1009. discountmod = 999;
  1010. }
  1011. }
  1012. }
  1013. }
  1014.  
  1015. return discountmod;
  1016. }
  1017.  
  1018. int timecf(int start, int desti, int time, int traintype)
  1019. {
  1020. int totaltime, arrivaltime;
  1021.  
  1022. if ((start == 1 && desti == 2 && traintype == 1) == 1)
  1023. {
  1024. totaltime = 130;
  1025. }
  1026. else
  1027. {
  1028. if ((start == 1 && desti == 3 && traintype == 1) == 1)
  1029. {
  1030. totaltime = 230;
  1031. }
  1032. else
  1033. {
  1034. if ((start == 2 && desti == 1 && traintype == 1) == 1)
  1035. {
  1036. totaltime = 130;
  1037. }
  1038. else
  1039. {
  1040. if ((start == 2 && desti == 3 && traintype == 1) == 1)
  1041. {
  1042. totaltime = 100;
  1043. }
  1044. else
  1045. {
  1046. if ((start == 3 && desti == 1 && traintype == 1) == 1)
  1047. {
  1048. totaltime = 230;
  1049. }
  1050. else
  1051. {
  1052. if ((start == 3 && desti == 2 && traintype == 1) == 1)
  1053. {
  1054. totaltime = 100;
  1055. }
  1056. else
  1057. {
  1058. if ((start == 1 && desti == 2 && traintype == 2) == 1)
  1059. {
  1060. totaltime = 145;
  1061. }
  1062. else
  1063. {
  1064. if ((start == 1 && desti == 3 && traintype == 2) == 1)
  1065. {
  1066. totaltime = 300;
  1067. }
  1068. else
  1069. {
  1070. if ((start == 2 && desti == 1 && traintype == 2) == 1)
  1071. {
  1072. totaltime = 145;
  1073. }
  1074. else
  1075. {
  1076. if ((start == 2 && desti == 3 && traintype == 2) == 1)
  1077. {
  1078. totaltime = 115;
  1079. }
  1080. else
  1081. {
  1082. if ((start == 3 && desti == 1 && traintype == 2) == 1)
  1083. {
  1084. totaltime = 300;
  1085. }
  1086. else
  1087. {
  1088. if ((start == 3 && desti == 2 && traintype == 2) == 1)
  1089. {
  1090. totaltime = 115;
  1091. }
  1092. else
  1093. {
  1094. if ((start == 1 && desti == 2 && traintype == 3) == 1)
  1095. {
  1096. totaltime = 245;
  1097. }
  1098. else
  1099. {
  1100. if ((start == 1 && desti == 3 && traintype == 3) == 1)
  1101. {
  1102. totaltime = 400;
  1103. }
  1104. else
  1105. {
  1106. if ((start == 2 && desti == 1 && traintype == 3) == 1)
  1107. {
  1108. totaltime = 245;
  1109. }
  1110. else
  1111. {
  1112. if ((start == 2 && desti == 3 && traintype == 3) == 1)
  1113. {
  1114. totaltime = 115;
  1115. }
  1116. else
  1117. {
  1118. if ((start == 3 && desti == 1 && traintype == 3) == 1)
  1119. {
  1120. totaltime = 400;
  1121. }
  1122. else
  1123. {
  1124. if ((start == 3 && desti == 2 && traintype == 3) == 1)
  1125. {
  1126. totaltime = 115;
  1127. }
  1128. else
  1129. {
  1130. }
  1131. }
  1132. }
  1133. }
  1134. }
  1135. }
  1136. }
  1137. }
  1138. }
  1139. }
  1140. }
  1141. }
  1142. }
  1143. }
  1144. }
  1145. }
  1146. }
  1147. }
  1148.  
  1149. arrivaltime = totaltime + time;
  1150.  
  1151. return arrivaltime;
  1152. }
  1153.  
  1154. void receiptf(int start, int desti, struct dates display, int time, int train, int seating, int arrivaltime, float fee)
  1155. {
  1156. system("CLS");
  1157.  
  1158. printf("\n\t\t\t\tReceipt");
  1159.  
  1160. switch (start)
  1161. {
  1162. case 1:
  1163. printf("\nStarting Station: Tokyo\n");
  1164. break;
  1165. case 2:
  1166. printf("\nStarting Station: Nagoya\n");
  1167. break;
  1168. case 3:
  1169. printf("\nStarting Station: Shin-Osaka\n");
  1170. break;
  1171. }
  1172.  
  1173. switch (desti)
  1174. {
  1175. case 1:
  1176. printf("\nDestination: Tokyo\n");
  1177. break;
  1178. case 2:
  1179. printf("\nDestination: Nagoya\n");
  1180. break;
  1181. case 3:
  1182. printf("\nDestination: Shin-Osaka\n");
  1183. break;
  1184. }
  1185.  
  1186. switch (seating)
  1187. {
  1188. case 1:
  1189. printf("\nSeating Type: First Class\n");
  1190. break;
  1191. case 2:
  1192. printf("\nSeating Type: Economy Class\n");
  1193. break;
  1194. }
  1195.  
  1196. switch (train)
  1197. {
  1198. case 1:
  1199. printf("\nTrain Type: Nozomi\n");
  1200. break;
  1201. case 2:
  1202. printf("\nTrain Type: Hikari\n");
  1203. break;
  1204. case 3:
  1205. printf("\nTrain Type: Kodama\n");
  1206. break;
  1207. }
  1208.  
  1209. switch (time)
  1210. {
  1211. case 1000:
  1212. printf("\nTime of Departure: 1000 hrs\n");
  1213. printf("\nTime of Arrival: %d hrs\n",arrivaltime);
  1214. break;
  1215. case 1200:
  1216. printf("\nTime of Departure: 1200 hrs\n");
  1217. printf("\nTime of Arrival: %d hrs\n",arrivaltime);
  1218. break;
  1219. }
  1220.  
  1221. printf("\nDate of Departure : %d/%d\n",display.dayd,display.monthd);
  1222. printf("\nFee : %.2f JPY\n",fee);
  1223. }
  1224.  
  1225. float feef(int start, int desti,int seattype, int traintype, float agediscmod, float discmod, struct dates display)
  1226. {
  1227. int distance_t,destichoice=0,seat_p;
  1228. float base_rate,base_price,datemod=0,date_p,fee;
  1229.  
  1230. switch (start)
  1231. {
  1232. case 1:
  1233. destichoice = 1;
  1234. break;
  1235. case 2:
  1236. destichoice = 2;
  1237. break;
  1238. case 3:
  1239. destichoice = 3;
  1240. break;
  1241. }
  1242. while (destichoice == 1)
  1243. {
  1244. switch (desti)
  1245. {
  1246. case 2:
  1247. distance_t = 342;
  1248. break;
  1249. case 3:
  1250. distance_t = 515;
  1251. break;
  1252. }
  1253. destichoice = 0;
  1254. }
  1255.  
  1256. while (destichoice == 2)
  1257. {
  1258. switch (desti)
  1259. {
  1260. case 1:
  1261. distance_t = 342;
  1262. break;
  1263. case 3:
  1264. distance_t = 173;
  1265. break;
  1266. }
  1267. destichoice = 0;
  1268. }
  1269.  
  1270. while (destichoice == 3)
  1271. {
  1272. switch (desti)
  1273. {
  1274. case 1:
  1275. distance_t = 515;
  1276. break;
  1277. case 2:
  1278. distance_t = 173;
  1279. break;
  1280. }
  1281. destichoice = 0;
  1282. }
  1283.  
  1284. switch (traintype)
  1285. {
  1286. case 1:
  1287. base_rate = 0.1;
  1288. break;
  1289. case 2:
  1290. base_rate = 0.07;
  1291. break;
  1292. case 3:
  1293. base_rate = 0.04;
  1294. break;
  1295. }
  1296.  
  1297. switch (seattype)
  1298. {
  1299. case 1:
  1300. seat_p = 500;
  1301. break;
  1302. case 2:
  1303. seat_p = 200;
  1304. break;
  1305. }
  1306.  
  1307. if (display.monthd == 12)
  1308. {
  1309. if ((display.dayd > 22 && display.dayd < 26) == 1)
  1310. {
  1311. datemod = 1.5;
  1312. }
  1313. }
  1314. else
  1315. {
  1316. datemod = 1.0;
  1317. }
  1318.  
  1319. //calculations
  1320. base_price = (base_rate * (distance_t*1.0)) + seat_p;
  1321. date_p = base_price * datemod;
  1322. fee = date_p * agediscmod * discmod;
  1323.  
  1324. return fee;
  1325. }
  1326.  
  1327. void receiptoutf(struct receipts receiptout)
  1328. {
  1329. FILE *fptr;
  1330.  
  1331. fptr = fopen("receipt.txt","w");
  1332.  
  1333. fprintf(fptr,"\t\t\t\tTokaido Shinkansen\n");
  1334. fprintf(fptr,"\n\t\t+===================================+");
  1335.  
  1336. switch (receiptout.start)
  1337. {
  1338. case 1:
  1339. fprintf(fptr,"\n\t\t|Starting Station: Tokyo |\n");
  1340. break;
  1341. case 2:
  1342. fprintf(fptr,"\n\t\t|Starting Station: Nagoya |\n");
  1343. break;
  1344. case 3:
  1345. fprintf(fptr,"\n\t\t|Starting Station: Shin-Osaka |\n");
  1346. break;
  1347. }
  1348.  
  1349. fprintf(fptr,"\t\t| |");
  1350.  
  1351. switch (receiptout.desti)
  1352. {
  1353. case 1:
  1354. fprintf(fptr,"\n\t\t|Destination: Tokyo |\n");
  1355. break;
  1356. case 2:
  1357. fprintf(fptr,"\n\t\tDestination: Nagoya |\n");
  1358. break;
  1359. case 3:
  1360. fprintf(fptr,"\n\t\tDestination: Shin-Osaka |\n");
  1361. }
  1362.  
  1363. fprintf(fptr,"\t\t| |");
  1364.  
  1365. switch (receiptout.seating)
  1366. {
  1367. case 1:
  1368. fprintf(fptr,"\n\t\t|Seating Type: First-Class |\n");
  1369. break;
  1370. case 2:
  1371. fprintf(fptr,"\n\t\t|Seating Type: Economy |\n");
  1372. break;
  1373. }
  1374.  
  1375. fprintf(fptr,"\t\t| |");
  1376.  
  1377. switch (receiptout.train)
  1378. {
  1379. case 1:
  1380. fprintf(fptr,"\n\t\t|Train Type: Nozomi |\n");
  1381. break;
  1382. case 2:
  1383. fprintf(fptr,"\n\t\t|Train Type: Hikari |\n");
  1384. break;
  1385. case 3:
  1386. fprintf(fptr,"\n\t\t|Train Type: Kodama |\n");
  1387. break;
  1388. }
  1389.  
  1390. fprintf(fptr,"\t\t| |");
  1391.  
  1392. switch (receiptout.time)
  1393. {
  1394. case 1000:
  1395. fprintf(fptr,"\n\t\t|Time of Departure: 1000 hrs |\n");
  1396. fprintf(fptr,"\t\t| |");
  1397. fprintf(fptr,"\n\t\t|Time of Arrival: %d hrs |\n",receiptout.arrivaltime);
  1398. break;
  1399. case 1200:
  1400. fprintf(fptr,"\n\t\t|Time of Departure: 1200 hrs |\n");
  1401. fprintf(fptr,"\t\t| |");
  1402. fprintf(fptr,"\n\t\t|Time of Arrival: %d hrs |\n",receiptout.arrivaltime);
  1403. break;
  1404. }
  1405.  
  1406. fprintf(fptr,"\t\t| |");
  1407.  
  1408. if ((receiptout.dayr > 9 && receiptout.dayr < 32) && (receiptout.monthr < 10) == 1)
  1409. {
  1410. fprintf(fptr,"\n\t\t|Date of Departure: %d/%d |\n",receiptout.dayr,receiptout.monthr);
  1411. }
  1412. else
  1413. {
  1414. if ((receiptout.monthr > 9 && receiptout.monthr < 13) && (receiptout.dayr < 10) == 1)
  1415. {
  1416. fprintf(fptr,"\n\t\t|Date of Departure: %d/%d |\n",receiptout.dayr,receiptout.monthr);
  1417. }
  1418. else
  1419. {
  1420. if (((receiptout.monthr > 9 && receiptout.monthr < 13) && (receiptout.dayr > 9 && receiptout.dayr < 32)) == 1)
  1421. {
  1422. fprintf(fptr,"\n\t\t|Date of Departure: %d/%d |\n",receiptout.dayr,receiptout.monthr);
  1423. }
  1424. else
  1425. {
  1426. fprintf(fptr,"\n\t\t|Date of Departure: %d/%d |\n",receiptout.dayr,receiptout.monthr);
  1427. }
  1428. }
  1429. }
  1430.  
  1431.  
  1432. fprintf(fptr,"\t\t| |");
  1433. fprintf(fptr,"\n\t\t|Fee: %3.2f JPY |\n",receiptout.fee);
  1434. fprintf(fptr,"\t\t+===================================+");
  1435.  
  1436. fclose(fptr);
  1437.  
  1438. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement