Advertisement
Imran1107048

Online Railway Ticket

Mar 9th, 2021
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. #include<iostream>
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4.  
  5. using namespace std;
  6.  
  7. string user;
  8. int password;
  9. int cost;
  10. int exitcode = 10;
  11.  
  12. void registerAccount()
  13. {
  14. cout << "Registration\n\n";
  15.  
  16. cout << "Enter user name: ";
  17. cin >> user;
  18.  
  19. cout << "Enter 3 digit pin number: ";
  20. cin >> password;
  21.  
  22. cout << "Registration Successful\n\n";
  23. }
  24.  
  25. void login()
  26. {
  27. cout << "Login\n\n";
  28.  
  29. string checkuser;
  30. cout << "Enter user name: ";
  31. cin >> checkuser;
  32.  
  33. int checkpassword;
  34. cout << "Enter 3 digit pin number: ";
  35. cin >> checkpassword;
  36.  
  37. if(user == checkuser && password == checkpassword){
  38. cout << "Login Success\n";
  39. }
  40. else{
  41. cout << "Username or Password is incorrect\n";
  42. _Exit(exitcode);
  43. }
  44. }
  45.  
  46. int counttotal(int choice, int noft)
  47. {
  48. if(choice == 1)
  49. return noft * 100;
  50. else if(choice == 2)
  51. return noft * 120;
  52. else if(choice == 3)
  53. return noft * 150;
  54. else if(choice == 4)
  55. return noft * 180;
  56. else if(choice == 5)
  57. return noft * 220;
  58. else
  59. return noft * 250;
  60. }
  61.  
  62. void buyTicket()
  63. {
  64. cout << "Menu List\n1) Buy Ticket \n2) Exit\n";
  65. cout << "Enter Choice: ";
  66. int choice;
  67. cin >> choice;
  68. if(choice == 1){
  69. cout << "1) Dhaka to Bhairab Bazar bdt 100\n";
  70. cout << "2) Dhaka to Brahman Baria bdt 120\n";
  71. cout << "1) Dhaka to Comilla bdt 150\n";
  72. cout << "1) Dhaka to Laksham bdt 180\n";
  73. cout << "1) Dhaka to Feni bdt 220\n";
  74. cout << "1) Dhaka to Chittagong bdt 250\n";
  75.  
  76. cout << "Enter where you want to go (1/2/3/4/5/6): ";
  77. int place;
  78. cin >> place;
  79. cout << "Enter number of tickets: ";
  80. int numberofticket;
  81. cin >> numberofticket;
  82.  
  83. int totalprice = counttotal(choice, numberofticket);
  84. cout << "Total Price: " << totalprice << endl;
  85. cost = totalprice;
  86. }
  87. else{
  88. _Exit(exitcode);
  89. }
  90. }
  91. int main()
  92. {
  93. registerAccount();
  94. login();
  95. buyTicket();
  96.  
  97. cout << "Enter payment of tickets: ";
  98. int payment;
  99. cin >> payment;
  100. if(cost == payment){
  101. cout << "Payment successful. Thank you for using the system.\n";
  102. }
  103. else{
  104. cout << "You have due.\n";
  105. }
  106. return 0;
  107. }
  108.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement