Advertisement
Guest User

Untitled

a guest
Dec 9th, 2018
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Main Module
  2. Start
  3. Call GlobalVar(count_p, count_s, p_min, p_max, s_min, s_max, count, c_profit, total, discount, index)
  4. Call Form()
  5. End
  6.  
  7. Module GlobalVar( out count_p, out count_s, out p_min, out p_max, out s_min, out s_max, out count, out c_profit, out total, out discount, out index)
  8.  
  9. count_p = 0, count_s = 0, p_min = 0, p_max = 0, s_min = 0, s_max = 0, count = 0, c_profit = 0, total = 0, discount = 0.2, index = 0
  10. Return
  11.  
  12. Module Form()
  13.  
  14. Call Title()
  15. Display " -------------- " , newline
  16. Display " | 1 - Register | " , newline
  17. Display " | 2 - Login | " , newline
  18. Display " | 3 - Exit | " , newline
  19. Display " -------------- " , newline
  20. Display " => "
  21. Read log
  22. Display newline
  23.  
  24. if (log == 1)
  25. Call Regist(reg_user, reg_pass)
  26. else
  27. if (log == 2)
  28. Call Login(reg_user, reg_pass)
  29. else
  30. if (log == 3)
  31. Display "Thank you for using our system!"
  32. else
  33. Display "Invalid Input!"
  34. Call Form()
  35. Endif
  36. Endif
  37. Endif
  38. Return
  39.  
  40. Module Title()
  41. Display " ------------------------------------------" , newline
  42. Display "| Welcome to VIR Online Bus Ticket Booking |" , newline
  43. Display " ------------------------------------------" , newline
  44. Return
  45.  
  46. Module Regist(out reg_user, out reg_pass)
  47.  
  48. user = ""
  49. Do
  50. Display " Enter Username: "
  51. Read reg_user
  52. user += reg_user
  53. Display newline
  54. Display " Enter Password: "
  55. Read reg_pass
  56. Display newline
  57. Display " Re-Enter Password: "
  58. Read reg_rpass
  59. while (reg_pass != reg_rpass)
  60. Call Form()
  61. Return
  62.  
  63. Module Login(in reg_user, in reg_pass)
  64.  
  65. Display " Enter Username: "
  66. Read user_id
  67. Display newline
  68. Display " Enter Password: "
  69. Read user_pass
  70. Display newline
  71.  
  72. if (user_id == "admin" && user_pass == " 1234")
  73. Call AdminPanel(c_profit, total, count_p, count_s, count)
  74. else
  75. if (user_id != reg_user && user_pass == reg_pass)
  76. Display " Invalid Username! " , newline
  77. Call Login(reg_user, reg_pass)
  78. else
  79. if (user_id == reg_user && user_pass != reg_pass)
  80. Display "Invalid Password!" , newline
  81. Call Login(reg_user, reg_pass)
  82. else
  83. if (user_id != reg_user && user_pass != reg_pass)
  84. Display " Invalid username & Password! " , newline
  85. Call Login(reg_user, reg_pass)
  86. else
  87. Call TicketSystem()
  88. Endif
  89. Endif
  90. Endif
  91. Endif
  92. Return
  93.  
  94.  
  95. Module AdminPanel(in c_profit, in total, in count_p, in count_s, in count)
  96.  
  97. Display " ------------------------ ", newline
  98. Display " | Welcome To Admin Panel | ", newline
  99. Display " ------------------------ ", newline , newline
  100.  
  101. Display " ------------------------- ", newline
  102. Display " | 1 - Transaction History | ", newline
  103. Display " | 2 - Company Profit | ", newline
  104. Display " | 3 - Total Sales | ", newline
  105. Display " | 4 - Min & Max Sales | ", newline
  106. Display " | 5 - Average Total Sales | ", newline
  107. Display " | 6 - User Login | ", newline
  108. Display " ------------------------- ", newline
  109. Display " => "
  110. Read admin
  111.  
  112. if (admin == 1)
  113. Call Transaction(user, phone, Location, Destination, day, month, year, b_time, seat, p_discount)
  114. else
  115. if (admin == 2)
  116. Call Profit(c_profit)
  117. else
  118. if (admin == 3)
  119. Call TotalSales(total)
  120. else
  121. if (admin == 4)
  122. Call MinMax(count_p, count_s)
  123. else
  124. if (admin == 5)
  125. Call Average(total, count)
  126. else
  127. if (admin == 6)
  128. Call Form()
  129. else
  130. Display " Invalid choice! "
  131. Call AdminPanel(c_profit, total, count_p, count_s, count)
  132. Endif
  133. Endif
  134. Endif
  135. Endif
  136. Endif
  137. Endif
  138. Return
  139.  
  140. Module Transaction(in user, in phone, in Location, in Destination, in day, in month, in year, in b_time, in seat, in p_discount)
  141.  
  142. Display " -------------------- ", newline
  143. Display " | Ticket Information | ", newline
  144. Display " -------------------- ", newline
  145. Display " ------------------------------------------------- ", newline
  146. Display " | Username : " , user , newline
  147. Display " | Phone Number : " , phone , newline
  148. Display " | Location : " , Location , newline
  149. Display " | Destination : " , Destination , newline
  150. Display " | Date Depart : " , day , '/' , month , '/' , year , newline
  151. Display " | Time Depart : " , b_time , newline
  152. Display " | Bus Type : " , b_type_ , newline
  153. Display " | Bus Seat : " , seat , newline
  154. Display " | Total Price : " , p_discount , newline
  155. Display " ------------------------------------------------ ", newline
  156. Display " Back to Admin Panel / User Login ? <A/U> ", newline
  157. Display " => "
  158. Read admin2
  159.  
  160. if (admin2 == 'A')
  161. Call AdminPanel(c_profit, total, count_p, count_s, count)
  162. else
  163. if (admin2 == 'U')
  164. Call Form()
  165. else
  166. Display " Invalid choice! ", newline
  167. Call AdminPanel(c_profit, total, count_p, count_s, count)
  168. Endif
  169. Endif
  170. Return
  171.  
  172. Module Profit(in c_profit)
  173. c_profit += (total * 0.3)
  174.  
  175. Display " Company Profit is : RM ", c_profit , newline
  176. Display " Back to Admin Panel / User Login ? <A/U> ", newline
  177. Display " => "
  178. Read admin2
  179.  
  180. if (admin2 == 'A')
  181. Call AdminPanel(c_profit, total, count_p, count_s, count)
  182. else
  183. if (admin2 == 'U')
  184. Form()
  185. else
  186. Display " Invalid choice! "
  187. Call AdminPanel(c_profit, total, count_p, count_s, count)
  188. Endif
  189. Endif
  190. Return
  191.  
  192. Module TotalSales(in total)
  193.  
  194. Display " Total Sales Today is : RM" , total , newline
  195.  
  196. Display " | Back to Admin Panel / User Login ? <A/U> | ", newline
  197. Display " => "
  198. Read admin2
  199.  
  200. if (admin2 == 'A')
  201. Call AdminPanel(c_profit, total, count_p, count_s, count)
  202. else
  203. if (admin2 == 'U')
  204. Call Form()
  205. else
  206. Display " Invalid choice! ", newline
  207. Call AdminPanel(c_profit, total, count_p, count_s, count)
  208. Endif
  209. Endif
  210. Return
  211.  
  212. Module MinMax(in count_p, in count_s)
  213.  
  214. if (count_p < count_s)
  215. Display " Minimum company sales is Perdana Express which is : " , count_p , newline
  216. Display " Maximum company sales is Sani Express which is : " , count_s , newline
  217. Endif
  218. if (count_s < count_p)
  219. Display " Minimum company sales is Sani Express which is : " , count_s , newline
  220. Display " Maximum company sales is Perdana Express which is : " , count_p , newline
  221. Endif
  222. if (count_s == count_p)
  223. Display " Company sales Perdana Express is equal to Sani Express which is : " , count_s , newline
  224. Endif
  225. Display " Back to Admin Panel / User Login ? <A/U> " , newline
  226. Display " => "
  227. Read admin2
  228. if (admin2 == 'A')
  229. Call AdminPanel(c_profit, total, count_p, count_s, count)
  230. else
  231. if (admin2 == 'U')
  232. Call Form()
  233. else
  234. Display " Invalid choice! " , newline
  235. Call AdminPanel(c_profit, total, count_p, count_s, count)
  236. Endif
  237. Endif
  238. Return
  239.  
  240. Module Average(in total, in count)
  241.  
  242. average = total / count
  243. Display " | Average total sales from " , count , " user today is : RM" , average , newline
  244. Display " | Back to Admin Panel / User Login ? <A/U> | " , newline
  245. Display " => "
  246. Read admin2
  247.  
  248. if (admin2 == 'A')
  249. Call AdminPanel(c_profit, total, count_p, count_s, count)
  250. else
  251. if (admin2 == 'U')
  252. Call Form()
  253. else
  254. Display " ----------------- " , newline
  255. Display " | Invalid choice! | " , newline
  256. Display " ----------------- " , newline
  257. Call AdminPanel(c_profit, total, count_p, count_s, count)
  258. Endif
  259. Endif
  260. Return
  261.  
  262. Module TicketSystem()
  263.  
  264. Call Title()
  265. Display " | Location | | Destination |" , newline
  266. Display " ------------ ------------- " , newline
  267. Display " | Kelantan | | Kelantan |" , newline
  268. Display " | Terengganu | | Terengganu |" , newline
  269. Display " | Pahang | | Pahang |" , newline
  270.  
  271. Display " Please Enter Your Location: "
  272. Read Location
  273. Display " Please Enter Your Destination: "
  274. Read Destination
  275.  
  276. Call Formula(p_ticket_discount)
  277. Call DepartDate(day, month, year)
  278.  
  279. Display newline
  280. Display " Enter Phone Number: "
  281. Read phone
  282. Display newline
  283.  
  284. Call BusType(b_type, count_p, count_s)
  285. Call Seat(seat)
  286. Return
  287.  
  288. Module Formula(out p_ticket_discount)
  289.  
  290. if (Location == "Kelantan")
  291. if (Destination == "Terengganu")
  292. p_ticket = 15.00
  293. p_discount = p_ticket * 0.8
  294. p_ticket_discount = p_ticket * discount
  295. else
  296. if (Destination == "Pahang")
  297. p_ticket = 35.00
  298. p_discount = p_ticket * 0.8
  299. p_ticket_discount = p_ticket * discount
  300. else
  301. Display " Invalid Destination "
  302. Endif
  303. Endif
  304. else
  305. if (Location == "Terengganu")
  306. if (Destination == "Kelantan")
  307. p_ticket = 15.00
  308. p_discount = p_ticket * 0.8
  309. p_ticket_discount = p_ticket * discount
  310. else
  311. if (Destination == "Pahang")
  312. p_ticket = 17.00
  313. p_discount = p_ticket * 0.8
  314. p_ticket_discount = p_ticket * discount
  315. else
  316. Display " Invalid Destination "
  317. Endif
  318. Endif
  319. else
  320. if (Location == "Pahang")
  321. if (Destination == "Kelantan")
  322. p_ticket = 35.00
  323. p_discount = p_ticket * 0.8
  324. p_ticket_discount = p_ticket * discount
  325. else
  326. if (Destination == "Terengganu")
  327.  
  328. p_ticket = 17.00
  329. p_discount = p_ticket * 0.8
  330. p_ticket_discount = p_ticket * discount
  331. else
  332. Display " Invalid Destination "
  333. Endif
  334. Endif
  335. else
  336. Display " Invalid Location! "
  337. Endif
  338. Endif
  339. Endif
  340. Return
  341.  
  342. Module DepartDate(out day, out month, out year)
  343.  
  344. Display " Please Enter Depart Date " , newline
  345. Display " | Day [DD]: | => "
  346. Read day
  347. Display newline
  348. Display " | Month [MM]: | => "
  349. Read month
  350. Display newline
  351. Display " | Year [YYYY]: | => "
  352. Read year
  353. Return
  354.  
  355. Module BusType(out b_type , out count_p, out count_s)
  356.  
  357. Display " --------------------- ---------- " , newline
  358. Display " | Bus Type | | Time | " , newline
  359. Display " --------------------- ---------- " , newline
  360. Display " | 1 - Perdana Express | | 9.00 A.M | " , newline
  361. Display " | 2 - Perdana Express | | 2.00 P.M | " , newline
  362. Display " | 3 - Perdana Express | | 6.30 P.M | " , newline
  363. Display " | 4 - Perdana Express | | 10.30 P.M| " , newline
  364. Display " | 5 - Sani Express | | 10.00 A.M| " , newline
  365. Display " | 6 - Sani Express | | 4.00 P.M | " , newline
  366. Display " | 7 - Sani Express | | 8.30 P.M | " , newline
  367. Display " | 8 - Sani Express | | 11.00 P.M| " , newline
  368. Display " --------------------- ---------- " , newline
  369.  
  370. Display " Please Enter The Number Of Bus Type "
  371. Read b_type
  372. Display newline
  373.  
  374. if(b_type == 1)
  375. b_type_ = "Perdana Express"
  376. b_time = "9.00 A.M"
  377. count_p++
  378. else
  379. if(b_type == 2)
  380. b_type_ = "Perdana Express"
  381. b_time = "2.00 P.M"
  382. count_p++
  383. else
  384. if(b_type == 3)
  385. b_type_ = "Perdana Express"
  386. b_time = "6.30 P.M"
  387. count_p++
  388. else
  389. if(b_type == 4)
  390. b_type_ = "Perdana Express"
  391. b_time = "10.30 P.M"
  392. count_p++
  393. else
  394. if(b_type == 4)
  395. b_type_ = "Perdana Express"
  396. b_time = "10.30 P.M"
  397. count_p++
  398. else
  399. if(b_type == 5)
  400. b_type_ = "Sani Express"
  401. b_time = "10.00 A.M"
  402. count_s++
  403. else
  404. if(b_type == 6)
  405. b_type_ = "Sani Express"
  406. b_time = "4.00 P.M"
  407. count_s++
  408. else
  409. if(b_type == 7)
  410. b_type_ = "Sani Express"
  411. b_time = "8.30 P.M"
  412. count_s++
  413. else
  414. if(b_type == 8)
  415. b_type_ = "Sani Express"
  416. b_time = "11.00 P.M"
  417. count_s++
  418. else(b_type > 8)
  419. Display "Invalid Choice"
  420. Endif
  421. Endif
  422. Endif
  423. Endif
  424. Endif
  425. Endif
  426. Endif
  427. Endif
  428. Endif
  429. Return
  430.  
  431. Module Seat(out seat)
  432.  
  433. cout << " Choose Seat :"
  434. Read seat
  435. Call Print_Ticket()
  436. Return
  437.  
  438. Module Print_Ticket(in Location, in Destination, in day, in month, in year, in b_time, in seat, in p_ticket, in p_ticket_discount, in p_discount, in user_id, in, phone, in index, in total, in count)
  439.  
  440. Display " -------------------- " , newline
  441. Display " | Ticket Information |" , newline
  442. Display " -------------------- " , newline
  443. Display " ------------------------------------------------- " , newline
  444. Display " | Location : " , Location , newline
  445. Display " | Destination : " , Destination , newline
  446. Display " | Date Depart : " , day , '/' , month , '/' , year , newline
  447. Display " | Time Depart : " , b_time , newline
  448. Display " | Bus Type : " , b_type_ , newline
  449. Display " | Bus Seat : " , seat , newline
  450. Display " | Ticket Price : RM" , p_ticket , newline
  451. Display " | Discount Price : RM" , p_ticket_discount , newline
  452. Display " | Ticket Discount : RM" , p_discount , newline
  453. Display " | Username : " , user_id , newline
  454. Display " | Phone Number : " , phone , newline
  455. Display " ------------------------------------------------ " , newline
  456.  
  457. index++
  458. total += p_discount
  459. count++
  460.  
  461. Display " | Do You Wish To Buy Another Ticket? <Y/N> | " , newline
  462. Display " => "
  463. Read choice
  464.  
  465. if (choice == 'Y')
  466. Call TicketSystem()
  467.  
  468. else
  469. if (choice == 'N')
  470. Display " | Thank You for using our program! | " , newline
  471. Call Form()
  472. else
  473. Display " | Invalid Choice! | " , newline
  474. Endif
  475. Endif
  476. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement