Advertisement
gh0st-00p

Christmas-competition

Dec 17th, 2012
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 4.96 KB | None | 0 0
  1. Module Module1
  2.     'Program compiled and written in Microsft Express 2012 Visual Basic .net
  3.     'Working in 95%
  4.     'But all the requiments for program has been succesfuly met.
  5.     'Written By Piotr Nierobisz For As Computing all copyrights reserved by Franklin College
  6.     'Declaring global variables for function
  7.     Dim na_me(15), amount(15), num1 As String
  8.     Sub Main()
  9.         Dim control, conf As Char
  10.         Dim quantity, num, day As Integer
  11.         Dim product(11), name As String
  12.         Dim price(11), oprice, calc As Single
  13.         product(0) = "Partridge in a pear tree"
  14.         product(1) = "Turtle Dove"
  15.         product(2) = "French Hen"
  16.         product(3) = "Calling Hen"
  17.         product(4) = "Gold Ring"
  18.         product(5) = "Geese-a-laying"
  19.         product(6) = "Swan-a-swimming"
  20.         product(7) = "Maid-a-walking"
  21.         product(8) = "Lady dancing"
  22.         product(9) = "Lord-a-leeping"
  23.         product(10) = "Piper Piping"
  24.         product(11) = "Drummer Drumming"
  25.         price(0) = "29.50"
  26.         price(1) = "25"
  27.         price(2) = "12"
  28.         price(3) = "18"
  29.         price(4) = "60"
  30.         price(5) = "48"
  31.         price(6) = "480"
  32.         price(7) = "120"
  33.         price(8) = "202.80"
  34.         price(9) = "292.50"
  35.         price(10) = "97.75"
  36.         price(11) = "205"
  37.         'Actual piece of code starts here
  38.         'Reseting num1 counter
  39.         store(2, 0, 0)
  40.         Do
  41.             Console.Clear()
  42.             'Reseting Counter in order to allow program to identify
  43.             'products and asking user for data
  44.             num = 0
  45.             Console.Write("Please enter product name [max 15] : ")
  46.             name = Console.ReadLine()
  47.             Console.Write("Please enter product quantity : ")
  48.             quantity = Console.ReadLine()
  49.             Do
  50.                 'Identifying product and sending info into database aka. array
  51.                 If name = product(num) Then
  52.                     oprice += price(num) * quantity
  53.                     store(0, name, quantity)
  54.                 End If
  55.                 num += 1
  56.             Loop Until num = 12
  57.             Console.Write("Is that all ? [y/n]")
  58.             conf = Console.ReadLine()
  59.             If conf = "y" Then
  60.                 Console.Clear()
  61.                 'Once all data has been inputed programs jump to this place
  62.                 Console.WriteLine("Checkout")
  63.                 Console.WriteLine()
  64.                 store(1, 0, 0)
  65.                 Console.WriteLine("--------------------------------------------------------------------------")
  66.                 Console.WriteLine("You will pay : " & oprice)
  67.                 Console.WriteLine("Press enter to continue")
  68.                 Console.ReadLine()
  69.                 control = "y"
  70.             End If
  71.         Loop Until control = "y"
  72.         'Additional bit enabling user to have any discounts
  73.         'No need to explain that bit - easy stuff
  74.         Console.Clear()
  75.         Console.WriteLine("One more thing before you go, what day of christmas is it ?")
  76.         day = Console.ReadLine()
  77.         Console.Clear()
  78.         Console.WriteLine("Checking for any available discounts")
  79.         If day < 10 Then
  80.             Console.WriteLine("Sorry no discounts for this day :(")
  81.             Console.WriteLine("You will pay : " & oprice)
  82.         ElseIf day = 10 Then
  83.             Console.WriteLine("10% discount for you sir !")
  84.             calc = 0.1 * oprice
  85.             oprice -= calc
  86.             Console.WriteLine("You will pay : " & oprice)
  87.         ElseIf day = 11 Then
  88.             Console.WriteLine("11% discount for you sir !")
  89.             calc = 0.11 * oprice
  90.             oprice -= calc
  91.             Console.WriteLine("You will pay : " & oprice)
  92.         ElseIf day = 12 Then
  93.             Console.WriteLine("12% discount for you sir !")
  94.             calc = 0.12 * oprice
  95.             oprice -= calc
  96.             Console.WriteLine("You will pay : " & oprice)
  97.         Else
  98.             Console.WriteLine("Sorry no discounts for this day :(")
  99.             Console.WriteLine("You will pay : " & oprice)
  100.         End If
  101.         Console.ReadLine()
  102.     End Sub
  103.     'Separate function which ideally stores all data and then throws it out at check out
  104.     'Altough no errors are present i think variables types are causing problem in case 0
  105.     'Case 2 should throw data in following format
  106.     'name_of_product    x quantity
  107.     Private Function store(ByVal opt As Integer, ByVal inp As String, ByVal q As String) As String
  108.         Select Case opt
  109.             Case 0
  110.                 na_me(num1) += inp
  111.                 amount(num1) += q
  112.                 num1 += 1
  113.                 Return "1"
  114.             Case 1
  115.                 For Each Str As String In na_me
  116.                     Console.WriteLine(Str)
  117.                 Next
  118.                 Return "1"
  119.             Case 2
  120.                 num1 = 0
  121.                 Return "1"
  122.             Case Else
  123.                 Return "0"
  124.         End Select
  125.     End Function
  126.  
  127. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement