Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Module Module1
- 'Program compiled and written in Microsft Express 2012 Visual Basic .net
- 'Working in 95%
- 'But all the requiments for program has been succesfuly met.
- 'Written By Piotr Nierobisz For As Computing all copyrights reserved by Franklin College
- 'Declaring global variables for function
- Dim na_me(15), amount(15), num1 As String
- Sub Main()
- Dim control, conf As Char
- Dim quantity, num, day As Integer
- Dim product(11), name As String
- Dim price(11), oprice, calc As Single
- product(0) = "Partridge in a pear tree"
- product(1) = "Turtle Dove"
- product(2) = "French Hen"
- product(3) = "Calling Hen"
- product(4) = "Gold Ring"
- product(5) = "Geese-a-laying"
- product(6) = "Swan-a-swimming"
- product(7) = "Maid-a-walking"
- product(8) = "Lady dancing"
- product(9) = "Lord-a-leeping"
- product(10) = "Piper Piping"
- product(11) = "Drummer Drumming"
- price(0) = "29.50"
- price(1) = "25"
- price(2) = "12"
- price(3) = "18"
- price(4) = "60"
- price(5) = "48"
- price(6) = "480"
- price(7) = "120"
- price(8) = "202.80"
- price(9) = "292.50"
- price(10) = "97.75"
- price(11) = "205"
- 'Actual piece of code starts here
- 'Reseting num1 counter
- store(2, 0, 0)
- Do
- Console.Clear()
- 'Reseting Counter in order to allow program to identify
- 'products and asking user for data
- num = 0
- Console.Write("Please enter product name [max 15] : ")
- name = Console.ReadLine()
- Console.Write("Please enter product quantity : ")
- quantity = Console.ReadLine()
- Do
- 'Identifying product and sending info into database aka. array
- If name = product(num) Then
- oprice += price(num) * quantity
- store(0, name, quantity)
- End If
- num += 1
- Loop Until num = 12
- Console.Write("Is that all ? [y/n]")
- conf = Console.ReadLine()
- If conf = "y" Then
- Console.Clear()
- 'Once all data has been inputed programs jump to this place
- Console.WriteLine("Checkout")
- Console.WriteLine()
- store(1, 0, 0)
- Console.WriteLine("--------------------------------------------------------------------------")
- Console.WriteLine("You will pay : " & oprice)
- Console.WriteLine("Press enter to continue")
- Console.ReadLine()
- control = "y"
- End If
- Loop Until control = "y"
- 'Additional bit enabling user to have any discounts
- 'No need to explain that bit - easy stuff
- Console.Clear()
- Console.WriteLine("One more thing before you go, what day of christmas is it ?")
- day = Console.ReadLine()
- Console.Clear()
- Console.WriteLine("Checking for any available discounts")
- If day < 10 Then
- Console.WriteLine("Sorry no discounts for this day :(")
- Console.WriteLine("You will pay : " & oprice)
- ElseIf day = 10 Then
- Console.WriteLine("10% discount for you sir !")
- calc = 0.1 * oprice
- oprice -= calc
- Console.WriteLine("You will pay : " & oprice)
- ElseIf day = 11 Then
- Console.WriteLine("11% discount for you sir !")
- calc = 0.11 * oprice
- oprice -= calc
- Console.WriteLine("You will pay : " & oprice)
- ElseIf day = 12 Then
- Console.WriteLine("12% discount for you sir !")
- calc = 0.12 * oprice
- oprice -= calc
- Console.WriteLine("You will pay : " & oprice)
- Else
- Console.WriteLine("Sorry no discounts for this day :(")
- Console.WriteLine("You will pay : " & oprice)
- End If
- Console.ReadLine()
- End Sub
- 'Separate function which ideally stores all data and then throws it out at check out
- 'Altough no errors are present i think variables types are causing problem in case 0
- 'Case 2 should throw data in following format
- 'name_of_product x quantity
- Private Function store(ByVal opt As Integer, ByVal inp As String, ByVal q As String) As String
- Select Case opt
- Case 0
- na_me(num1) += inp
- amount(num1) += q
- num1 += 1
- Return "1"
- Case 1
- For Each Str As String In na_me
- Console.WriteLine(Str)
- Next
- Return "1"
- Case 2
- num1 = 0
- Return "1"
- Case Else
- Return "0"
- End Select
- End Function
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement