Advertisement
Talithacelin

Ticket Train

Nov 6th, 2022 (edited)
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.32 KB | None | 0 0
  1. #recommend train
  2. import datetime
  3. import sys
  4. now = datetime.datetime.now()
  5. hour = now.hour
  6. time = now.strftime("%H:%M")
  7. date = now.strftime("%d/%m/%Y")
  8.  
  9. from datetime import datetime, timedelta
  10. now = datetime.today()
  11.  
  12. he = now + timedelta(minutes=15)
  13. time15 = he.strftime("%H:%M")
  14.  
  15. list = ["S Train = 4500 gils each | 30 minutes" , "A Train = 3500 gils each | 40 minutes" , "B Train = 2500 gils each | 60 minutes" , "C Train = 1500 gils each | 75 minutes"]
  16. S = 4500  
  17. A = 3500  
  18. B = 2500  
  19. C = 1500
  20.  
  21. #1000-2000 , 2000-3000 , 3000-4000 , 5000-6000
  22. print()
  23.  
  24.  
  25. print("Train to Gridania")
  26. print(20*'-')
  27. user = input("Please type your name = ")
  28. if hour < 12:
  29.     greeting = f"Good morning {user}!"
  30. elif hour < 18:
  31.     greeting = f"Good afternoon {user}!"
  32. else:
  33.     greeting = f"Good evening {user}!"
  34.  
  35. print()
  36. print(greeting)
  37. print(f"Today is {date}. The time is {time}.")
  38. ready = input("Order ticket? (yes/no): ")
  39.  
  40. while ready == "yes" :
  41.     try:
  42.         print()
  43.         peeps = int(input("How many people? "))
  44.         budget = int(input("Please enter a budget for each person (1000-5000 gils) : "))
  45.    
  46.         if budget < 1000 or budget > 5000:
  47.             raise ValueError
  48.    
  49.         elif budget >= 1000 and budget <= 2000 :
  50.              print("~~ C Train. Duration 75 minutes. ~~")        
  51.         elif budget >= 2000 and budget <= 3000 :
  52.              print("~~ B Train. Duration 60 minutes. ~~")      
  53.         elif budget >= 3000 and budget <= 4000 :
  54.              print("~~ A Train. Duration 40 minutes. ~~")      
  55.         else:
  56.              print("~~ S Train. Duration 30 minutes. ~~")      
  57.  
  58.         again = input("Confirm choice? (yes/no) ")
  59.         if again == 'yes' :
  60.             print(20*'-')
  61.             for i in list:
  62.                 print(i)
  63.             print(20*'-')
  64.  
  65.             if budget >= 1000 and budget <= 2000 :
  66.                 order = peeps * C
  67.                 print(f"Passenger {user} boarding C Train for {peeps} people.")
  68.                 print(f"Total payment: {order} gils")
  69.                 print("Train leaving in 15 minutes from now.")
  70.            
  71.             elif budget >= 2000 and budget <= 3000 :
  72.                 order = peeps * B
  73.                 print(f"Passenger {user} boarding B Train for {peeps} people.")
  74.                 print(f"Total payment: {order} gils")
  75.                 print("Train leaving in 15 minutes from now.")
  76.            
  77.             elif budget >= 3000 and budget <= 4000 :
  78.                 order = peeps * A
  79.                 print(f"Passenger {user} boarding A Train for {peeps} people.")
  80.                 print(f"Total payment: {order} gils")
  81.                 print("Train leaving in 15 minutes from now.")
  82.            
  83.             elif budget >= 4000 and budget <= 5000 :
  84.                 order = peeps * S
  85.                 print(f"Passenger {user} boarding S Train for {peeps} people.")
  86.                 print(f"Total payment: {order} gils")
  87.                 print("Train leaving in 15 minute from now.")
  88.  
  89.             reenter = input("Confirm your train name: (C/B/A/S) ")
  90.             confirm = input("Confirm order? " )
  91.             while confirm == 'yes':
  92.                 pay = order
  93.                 print()
  94.                 pay = int(input("Please input an amount of money: "))
  95.  
  96.                 if pay < order :
  97.                     print("Oops. Not enough. Please reenter amount.")
  98.                     print()
  99.                     continue
  100.  
  101.                 elif pay == order:
  102.                     print(f"Exact amount of {order} gils received. Thanks !")
  103.                     change = 0
  104.                     print()
  105.                     print("HERE'S YOUR TICKET")
  106.                     print("-----------------------------------------")
  107.                     print("| Train to Gridania Ticket")
  108.                     print(f"| Passenger: {user}")
  109.                     print(f"| Boarding {reenter} Train for {peeps} people")
  110.                     print(f"| -> Train will be leaving at: {time15}")
  111.                     print(f"| Total payment: {order}")
  112.                     print(f"| Change: {change}")
  113.                     print(f"| Printed: {date}")
  114.                     print("-----------------------------------------")
  115.                     print("THANK YOU!")
  116.                     sys.exit()
  117.  
  118.                 else:
  119.                     change = pay - order
  120.                     print(f"{pay} gils received. Here's your change!")
  121.                     print(f"Output: ${change}. Thanks!")
  122.                     print()
  123.                     print("HERE'S YOUR TICKET")
  124.                     print("-----------------------------------------")
  125.                     print("| Train to Gridania Ticket")
  126.                     print(f"| Passenger: {user}")
  127.                     print(f"| Boarding {reenter} Train for {peeps} people")
  128.                     print(f"| -> Train will be leaving at: {time15}")
  129.                     print(f"| Total payment: {order}")
  130.                     print(f"| Change: {change}")
  131.                     print(f"| Printed: {date}")
  132.                     print("-----------------------------------------")
  133.                     print("THANK YOU!")
  134.                     sys.exit()
  135.  
  136.                
  137.         else:
  138.             print()
  139.             continue
  140.  
  141.     except ValueError:
  142.         print("! Not a valid input !")
  143.         print("Please enter as stated.")
  144.         print()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement