Advertisement
gnamp

Taxi Fare Calculator - Small Basic

Jul 16th, 2012
584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Durham Taxi Fare Calculator
  2. '(c) Dominic McGough September 2011
  3. '(~Small Basic~)
  4.  
  5. TextWindow.Title = "DCC Taxi Fare Calculator ~ Dominic McGough 2011"
  6.  
  7. 'Change Font display colours here:-
  8.  
  9. 'main:-
  10. pen1 = "gray"
  11. 'result:-
  12. pen2 = "darkred"
  13. 'header:-
  14. pen3 = "darkgray"
  15. 'user ink:-
  16. pen4 = "darkyellow"
  17.  
  18. TextWindow.ForegroundColor = pen3
  19.  
  20.  
  21. TextWindow.WriteLine("Durham County Council Taxi Fare Calculator")
  22. TextWindow.WriteLine("---- Dominic McGough ~ September 2011 ----")
  23. 'TextWindow.WriteLine(" ")
  24. TextWindow.WriteLine("------------------------------------------")
  25. TextWindow.WriteLine(" ")
  26. TextWindow.WriteLine(" ")
  27.  
  28. start:
  29. TextWindow.ForegroundColor = pen1
  30. TextWindow.Write("Input Distance (in miles): ")
  31. TextWindow.ForegroundColor = pen4
  32. Miles = TextWindow.Read()
  33. TextWindow.ForegroundColor = pen1
  34.  
  35. 'convert miles to yards
  36. yards = Miles * 1760
  37.  
  38. TextWindow.WriteLine(" ")
  39. TextWindow.Write("Input Tariff (1-6): ")
  40. TextWindow.ForegroundColor = pen4
  41. Tariff = TextWindow.Read()
  42. TextWindow.ForegroundColor = pen1
  43. TextWindow.WriteLine(" ")
  44.  
  45. If Tariff = 1 Then
  46.   'below: (((yards - [1st x number of yards])/'[per y unit distance thereafter]' *[z pence])
  47.  '+ [£2.55 (for the first 500 yards or less)]
  48.  Price = (((yards - 500)/101.8)* .10) + 2.55
  49.  
  50.   'below: formula for getting 1 decimal place!!
  51.  Price = Math.Floor(Price*Math.Power(10,1))/Math.Power(10,1)
  52.   TextWindow.Write("The fare will be ** " )
  53.   TextWindow.ForegroundColor = pen2
  54.   TextWindow.Write("£")
  55.   TextWindow.Write(Price)
  56.   TextWindow.ForegroundColor = pen1
  57.   TextWindow.WriteLine(" **")
  58.   TextWindow.WriteLine(" ")
  59.   TextWindow.WriteLine("(As set by Durham County Council, September 2011)")
  60.   TextWindow.WriteLine(" ")
  61. EndIf
  62.  
  63. 'all other Tariff options follow above formula format using their own respective values
  64.  
  65. If Tariff = 2 Then
  66.   Price = (((yards - 500)/112) * .15) + 3.15
  67.   Price = Math.Floor(Price*Math.Power(10,1))/Math.Power(10,1)
  68.   TextWindow.Write("The fare will be ** " )
  69.   TextWindow.ForegroundColor = pen2
  70.   TextWindow.Write("£")
  71.   TextWindow.Write(Price)
  72.   TextWindow.ForegroundColor = pen1
  73.   TextWindow.WriteLine(" **")
  74.   TextWindow.WriteLine(" ")
  75.   TextWindow.WriteLine("(As set by Durham County Council, September 2011)")
  76.   TextWindow.WriteLine(" ")
  77. EndIf
  78.  
  79. If Tariff = 3 Then
  80.   Price = (((yards - 500)/97.4) * .20) + 4.40
  81.   Price = Math.Floor(Price*Math.Power(10,1))/Math.Power(10,1)
  82.   TextWindow.Write("The fare will be ** " )
  83.   TextWindow.ForegroundColor = pen2
  84.   TextWindow.Write("£")
  85.   TextWindow.Write(Price)
  86.   TextWindow.ForegroundColor = pen1
  87.   TextWindow.WriteLine(" **")
  88.   TextWindow.WriteLine(" ")
  89.   TextWindow.WriteLine("(As set by Durham County Council, September 2011)")
  90.   TextWindow.WriteLine(" ")
  91.   TextWindow.WriteLine("Hey, it's Christmas-time for er... goodness' sake!!")
  92.   TextWindow.WriteLine(" ")
  93.   TextWindow.WriteLine("Do you really think I want to be out here driving you around when I could be at home getting sozzled, stuffing my face & spending time with people whom I ")
  94.   TextWindow.WriteLine ("actually care about?!")
  95. EndIf
  96.  
  97. If Tariff = 4 Then
  98.   Price = (((yards - 500)/101.8) * .15) + 3.35
  99.   Price = Math.Floor(Price*Math.Power(10,1))/Math.Power(10,1)
  100.   TextWindow.Write("The fare will be ** " )
  101.   TextWindow.ForegroundColor = pen2
  102.   TextWindow.Write("£")
  103.   TextWindow.Write(Price)
  104.   TextWindow.ForegroundColor = pen1
  105.   TextWindow.WriteLine(" **")
  106.   TextWindow.WriteLine(" ")
  107.   TextWindow.WriteLine("(As set by Durham County Council, September 2011)")
  108.   TextWindow.WriteLine(" ")
  109.   TextWindow.WriteLine("No joke- it really is this price for a six-seater run!")
  110. EndIf
  111.  
  112. If Tariff = 5 Then
  113.   Price = (((yards - 500)/112) * .20) + 4.15
  114.   Price = Math.Floor(Price*Math.Power(10,1))/Math.Power(10,1)
  115.   TextWindow.Write("The fare will be ** " )
  116.   TextWindow.ForegroundColor = pen2
  117.   TextWindow.Write("£")
  118.   TextWindow.Write(Price)
  119.   TextWindow.ForegroundColor = pen1
  120.   TextWindow.WriteLine(" **")
  121.   TextWindow.WriteLine(" ")
  122.   TextWindow.WriteLine("(As set by Durham County Council, September 2011)")
  123.   TextWindow.WriteLine(" ")
  124.   TextWindow.WriteLine("No joke- it really is this price for a six-seater run!")
  125. EndIf
  126.  
  127. If Tariff = 6 Then
  128.   Price = (((yards - 500)/97.4) * .35) + 5.50
  129.   Price = Math.Floor(Price*Math.Power(10,1))/Math.Power(10,1)
  130.   TextWindow.Write("The fare will be ** " )
  131.   TextWindow.ForegroundColor = pen2
  132.   TextWindow.Write("£")
  133.   TextWindow.Write(Price)
  134.   TextWindow.ForegroundColor = pen1
  135.   TextWindow.WriteLine(" **")
  136.   TextWindow.WriteLine(" ")
  137.   TextWindow.WriteLine("(As set by Durham County Council, September 2011)")
  138.   TextWindow.WriteLine(" ")
  139.   TextWindow.WriteLine("Hey, it's Christmas-time for er... goodness' sake!!")
  140.   TextWindow.WriteLine(" ")
  141.   TextWindow.WriteLine("Do you really think I want to be out here driving you around when I could be at home getting sozzled, stuffing my face & spending time with people whom I ")
  142.   TextWindow.WriteLine ("actually care about?!")
  143. EndIf
  144.  
  145. If Tariff < 1 Or Tariff > 6 then
  146.   TextWindow.WriteLine("Error! Insert a number between 1 and 6!")
  147.   Goto start  
  148. EndIf
  149.  
  150. 'code for 'Retry' option (to recalculate using different values)
  151. TextWindow.WriteLine(" ")
  152. TextWindow.WriteLine(" ")
  153. TextWindow.Write("Go again? (y/n): ")
  154. AgainOrQuit = TextWindow.Read()
  155. TextWindow.WriteLine(" ")
  156. If AgainOrQuit = "y" Then
  157.   Goto start
  158. Else
  159.   TextWindow.WriteLine(" ")
  160.   TextWindow.WriteLine("No? OK- See ya later, Navigator!")
  161.   TextWindow.WriteLine(" ")
  162.   TextWindow.WriteLine(" ")
  163.   'pic
  164.  TextWindow.WriteLine(".                  ---   [\")
  165.   TextWindow.WriteLine(".          ------   .----' `-----.")
  166.   TextWindow.WriteLine(".     --- --- ---  //^^^^;;^^^^^^`\")
  167.   TextWindow.WriteLine(".   - ---- _______//_____||_____()_\________")
  168.   TextWindow.WriteLine(". ------  /3363   :      : ___              `\")
  169.   TextWindow.WriteLine(". ----   |>   ____;      ;  |/\><|   ____   _<)")
  170.   TextWindow.WriteLine(". ----  {____/    \_________________/    \____}")
  171.   TextWindow.WriteLine(".            \ '' /                 \ '' /")
  172.   TextWindow.WriteLine(". |> <> /\/\  '--'                   '--'")
  173.   TextWindow.WriteLine(". ")
  174.   TextWindow.WriteLine(". ")
  175.  
  176. EndIf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement