Advertisement
veronikaaa86

10. Small Shop

Sep 13th, 2022
1,365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub LiveDemo()
  2.     Dim quantity, result As Double
  3.     quantity = 3
  4.     result = quantity * ReturnAmount("water", "Plovdiv")
  5.    
  6.     Debug.Print result
  7. End Sub
  8.  
  9.  
  10. Function ReturnAmount(product, town As String)
  11.     If product = "coffee" Then
  12.         If town = "Sofia" Then
  13.             ReturnAmount = 0.5
  14.         ElseIf town = "Plovdiv" Then
  15.             ReturnAmount = 0.4
  16.         ElseIf town = "Varna" Then
  17.             ReturnAmount = 0.45
  18.         End If
  19.     ElseIf product = "water" Then
  20.         If town = "Sofia" Then
  21.             ReturnAmount = 0.8
  22.         ElseIf town = "Plovdiv" Then
  23.             ReturnAmount = 0.7
  24.         ElseIf town = "Varna" Then
  25.             ReturnAmount = 0.7
  26.         End If
  27.     ElseIf product = "beer" Then
  28.         If town = "Sofia" Then
  29.             ReturnAmount = 1.2
  30.         ElseIf town = "Plovdiv" Then
  31.             ReturnAmount = 1.15
  32.         ElseIf town = "Varna" Then
  33.             ReturnAmount = 1.1
  34.         End If
  35.     ElseIf product = "sweets" Then
  36.         If town = "Sofia" Then
  37.             ReturnAmount = 1.45
  38.         ElseIf town = "Plovdiv" Then
  39.             ReturnAmount = 1.3
  40.         ElseIf town = "Varna" Then
  41.             ReturnAmount = 1.35
  42.         End If
  43.     ElseIf product = "peanuts" Then
  44.         If town = "Sofia" Then
  45.             ReturnAmount = 1.6
  46.         ElseIf town = "Plovdiv" Then
  47.             ReturnAmount = 1.5
  48.         ElseIf town = "Varna" Then
  49.             ReturnAmount = 1.55
  50.         End If
  51.     End If
  52.    
  53. End Function
  54.  
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement