Advertisement
Guest User

Untitled

a guest
Mar 12th, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 9.95 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void menu();
  5. void departure();
  6. void checkAccount();
  7.  
  8.  
  9. char Username[50];
  10. char Password[50];
  11. char email[50],newName[50];
  12. char cancel;
  13. int phone;
  14. float price,total;
  15. int y,origin,dest,deptdd,deptmm,deptyy,retdd,retmm,retyy;
  16. int num_person;
  17. int departure_time;
  18. int return_time;
  19. char accno[20];
  20.  
  21. //============================================================================================================================//
  22.  
  23. void Login()
  24.  
  25. {
  26.     printf("\n");
  27.     printf("Username: ");
  28.     scanf("%s", &Username);
  29.     printf("\n");
  30.     printf("\nPassword: ");
  31.     scanf("%s", &Password);
  32.  
  33. }
  34.  
  35. //============================================================================================================================//
  36.  
  37. void checkLogin()
  38.  
  39. {
  40.  
  41.     if(strcmp(Username,"Namira") == 0 || strcmp(Username,"Ahmad_Ali") == 0 || strcmp(Username,"Nuha_Ali") == 0 ||
  42.        strcmp(Username,"Amalin") == 0|| strcmp(Username,"Ammar") == 0)
  43.     {
  44.         if(strcmp(Password,"Mira") == 0 || strcmp(Password,"doubleA") == 0 || strcmp(Password,"NH") == 0 ||
  45.            strcmp(Password,"amal") == 0 || strcmp(Password,"ammarI") == 0){
  46.             printf("You have logged in successfully.\n");
  47.         }
  48.  
  49.         else{
  50.             printf("Wrong username or password.");
  51.             exit(1);
  52.             }
  53.     }
  54.  
  55.     else{
  56.         printf("Wrong username or password.");
  57.         exit(1);
  58.         }
  59.  
  60.      printf("\n\t************************************************************");
  61.      printf("\n\t************************************************************");
  62.      system("cls");
  63.  
  64. }
  65.  
  66. //============================================================================================================================//
  67.  
  68. int main()
  69.  
  70. {
  71.  
  72.     int num1;
  73.  
  74.     printf("\n\t************************************************************");
  75.     printf("\n\t************************************************************");
  76.     printf("\n\t************************************************************");
  77.     printf("\n\t********                                            ********");
  78.     printf("\n\t********             PERFECT YOUR JOURNEY           ********");
  79.     printf("\n\t********             TRAIN TICKET ONLINE            ********");
  80.     printf("\n\t********              GET YOUR OWN NOW!             ********");
  81.     printf("\n\t********                                            ********");
  82.     printf("\n\t************************************************************");
  83.     printf("\n\t************************************************************");
  84.     printf("\n\t************************************************************");
  85.  
  86.  
  87.      printf("\n");
  88.      printf("\n");
  89.      printf("\nDo you have an existing account?");
  90.      printf("\n");
  91.      printf("\n");
  92.  
  93.  
  94.      printf("\n(1-yes/2-no): ");
  95.      scanf("%d",&y);
  96.      system("cls");
  97.  
  98.  
  99.     if(y==1){
  100.         Login();
  101.         checkLogin();
  102.         menu();
  103.  
  104.     }
  105.  
  106.     else{
  107.         printf("\nCreate new account");
  108.         printf("\n");
  109.         printf("\nEmail: ");
  110.         scanf("%s",&email);
  111.         printf("\nNo.phone: ");
  112.         scanf("%d",&phone);
  113.         printf("\nUsername: ");
  114.         scanf("%s",&newName);
  115.         system("cls");
  116.         menu();
  117.         }
  118.  
  119.  
  120.     return 0;
  121.  
  122. }
  123.  
  124.  
  125. //============================================================================================================================//
  126.  
  127. void menu()
  128.  
  129. {
  130.  
  131.     printf("\n\t************************************************************");
  132.     printf("\n\t************************************************************");
  133.  
  134.  
  135.      printf("\nChoose Your Origin");
  136.      printf("\n^*^*^*^*^*^*^*^*^");
  137.      printf("\n1 - Johor bahru");
  138.      printf("\n2 - Seremban");
  139.      printf("\n3 - Kuala Lumpur");
  140.      printf("\n4 - Kuantan");
  141.      printf("\n^*^*^*^*^*^*^*^*^");
  142.      printf("\nEnter Your Origin: ");
  143.      scanf("%d",&origin);
  144.      system("cls");
  145.  
  146.  
  147.      switch(origin)
  148.  
  149.      {
  150.  
  151.     case 1:
  152.       printf("\nChoose Your Destination");
  153.       printf("\n^*^*^*^*^*^*^*^*^*^*^");
  154.       printf("\nN1 Johor Bahru -> Bangi ");
  155.       printf("\nN2 Johor Bahru -> Kuantan ");
  156.       printf("\nN3 Johor Bahru -> Melaka ");
  157.       printf("\nN4 Johor Bahru -> Kedah ");
  158.       printf("\n^*^*^*^*^*^*^*^*^*^*^");
  159.       printf("\n\nPress 1-4 to choose the destination or\n");
  160.       printf("Press anything to cancel.\n");
  161.       printf("Option: ");
  162.       scanf("%d",&dest);
  163.       if(dest==1){
  164.         price=40.80;
  165.       }else if(dest==2){
  166.         price=54.99;
  167.       }else if(dest==3){
  168.         price=25.50;
  169.       }else {
  170.         price=70.20;
  171.       }
  172.       system("cls");
  173.       if(dest==1 || dest==2 || dest==3 || dest==4)
  174.     {
  175.         departure();
  176.     }
  177.     else
  178.     {
  179.             system("cls");
  180.             main();
  181.     }
  182.       departure(price);
  183.       break;
  184.  
  185.  
  186.     case 2:
  187.       printf("\nChoose Your Destination");
  188.       printf("\n^*^*^*^*^*^*^*^*^*^*^");
  189.       printf("\nN1 Seremban -> Kuala Lumpur ");
  190.       printf("\nN2 Seremban -> Johor Bahru ");
  191.       printf("\nN3 Seremban -> Melaka ");
  192.       printf("\nN4 Seremban -> Perlis ");
  193.       printf("\n^*^*^*^*^*^*^*^*^*^*^");
  194.       printf("\n\nPress 1-4 to choose the destination or\n");
  195.       printf("Press anything to cancel.\n");
  196.       printf("Option: ");
  197.       scanf("%d",&dest);
  198.       if(dest==1){
  199.         price=15.20;
  200.       }else if(dest==2){
  201.         price=38.30;
  202.       }else if(dest==3){
  203.         price=10.50;
  204.       }else {
  205.         price=54.60;
  206.       }
  207.       system("cls");
  208.       if(dest==1 || dest==2 || dest==3 || dest==4)
  209.    {
  210.         departure();
  211.     }
  212.     else
  213.     {
  214.             system("cls");
  215.             main();
  216.     }
  217.       departure(price);
  218.       break;
  219.  
  220.  
  221.     case 3:
  222.       printf("\nChoose Your Destination");
  223.       printf("\n^*^*^*^*^*^*^*^*^*^*^*^*^*^*^");
  224.       printf("\nN1 Kuala Lumpur -> Kuala Pilah");
  225.       printf("\nN2 Kuala Lumpur -> Kuantan ");
  226.       printf("\nN3 Kuala Lumpur -> segamat ");
  227.       printf("\nN4 Kuala Lumpur -> Nilai ");
  228.       printf("\n^*^*^*^*^*^*^*^*^*^*^*^*^*^*^");
  229.       printf("\n\nPress 1-4 to choose the destination or\n");
  230.       printf("Press anything to cancel.\n");
  231.       printf("Option: ");
  232.       scanf("%d",&dest);
  233.       if(dest==1){
  234.         price=20.02;
  235.       }else if(dest==2){
  236.         price=30.05;
  237.       }else if(dest==3){
  238.         price=18.90;
  239.       }else {
  240.         price=11.70;
  241.       }
  242.       system("cls");
  243.       if(dest==1 || dest==2 || dest==3 || dest==4)
  244.     {
  245.         departure();
  246.     }
  247.     else
  248.     {
  249.             system("cls");
  250.             main();
  251.     }
  252.       departure(price);
  253.       break;
  254.  
  255.  
  256.     case 4:
  257.       printf("\nChoose Your Destination");
  258.       printf("\n^*^*^*^*^*^*^*^*^*^*^*^*^*^*^");
  259.       printf("\nN1 Kuantan -> Kuala Pilah");
  260.       printf("\nN2 Kuantan -> Johor Bahru ");
  261.       printf("\nN3 Kuantan -> segamat ");
  262.       printf("\nN4 Kuantan -> Nilai ");
  263.       printf("\n^*^*^*^*^*^*^*^*^*^*^*^*^*^*^");
  264.       printf("\n\nPress 1-4 to choose the destination or\n");
  265.       printf("Press anything to cancel.\n");
  266.       printf("Option: ");
  267.       scanf("%d",&dest);
  268.      if(dest==1){
  269.         price=48.40;
  270.       }else if(dest==2){
  271.         price=50.30;
  272.       }else if(dest==3){
  273.         price=23.10;
  274.       }else {
  275.         price=30.30;
  276.       }
  277.       system("cls");
  278.       if(dest==1 || dest==2 || dest==3 || dest==4)
  279.     {
  280.         departure();
  281.     }
  282.     else
  283.     {
  284.             system("cls");
  285.             main();
  286.     }
  287.       departure(price);
  288.       break;
  289.  
  290.  
  291.     default:
  292.         printf("Wrong option\n");
  293.       }
  294.  
  295. }
  296.  
  297. //============================================================================================================================//
  298.  
  299. void departure(int num1)
  300.  
  301. {
  302.  
  303.     printf("\nDeparture Date(14/07/17):");
  304.     scanf("%d/%d/%d",&deptdd,&deptmm,&deptyy);
  305.     printf("\nReturn Date(16/07/17): ");
  306.     scanf("%d/%d/%d",&retdd,&retmm,&retyy);
  307.     printf("\nNumber Of Person: ");
  308.     scanf("%d",&num_person);
  309.     system("cls");
  310.  
  311.  
  312.     total=price*num_person;
  313.  
  314.  
  315.      printf("\n\t----------------------------------------");
  316.      printf("\n\t----------------------------------------");
  317.      printf("\n\t|      Departure Date:   %d/%d/%d      |",deptdd,deptmm,deptyy);
  318.      printf("\n\t|      Return date:      %d/%d/%d      |",retdd,retmm,retyy);
  319.      printf("\n\t|      Number of person: %d             |",num_person);
  320.      printf("\n\t|      Departure Time:   14:35         |",departure_time);
  321.      printf("\n\t|      Return Time:      09:15         |",return_time);
  322.      printf("\n\t|      Total Price:      %.2f        |",total);
  323.      printf("\n\t----------------------------------------");
  324.      printf("\n\t----------------------------------------");
  325.      printf("\n");
  326.      printf("\n");
  327.  
  328.  
  329.      printf("Your receipt will sending to your email");
  330.      printf("\nEnter your account number: ");
  331.      scanf("%s", &accno);
  332.      system("cls");
  333.      checkAccount();
  334. }
  335.  
  336.  
  337. //============================================================================================================================//
  338.  
  339. void checkAccount()
  340.  
  341. {
  342.     if(strcmp(accno,"1234567890") == 0|| strcmp(accno,"9876543210") == 0|| strcmp(accno,"2345678910") == 0||
  343.        strcmp(Username,"3456789120") == 0|| strcmp(accno,"4567891230")==0){
  344.          system("cls");
  345.          printf("\n\t***********************************************");
  346.          printf("\n\t***********************************************");
  347.          printf("\n");
  348.          printf("\n\tYOUR TRANSACTION IS SUCCESSFUL!");
  349.          printf("\n\tThank You for using our service");
  350.          printf("\n\tContact us if you have any problems 0196387893.");
  351.          printf("\n");
  352.          printf("\n\t***********************************************");
  353.          printf("\n\t***********************************************");
  354.          exit(1);
  355.     }
  356.  
  357.     else{
  358.         printf("Wrong account number.");
  359.         exit(1);
  360.  
  361.         }
  362.  
  363. }
  364.  
  365. //============================================================================================================================//
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement