Search 73,039 tutors
0 0

## Using Visual Basic write Program

Cost of Flash Drives: A Company sells 8 GB flash drives for \$3.300 each and 16 GB flash drives for \$5.20 each. However, large-quantity orders of flash drives of the same type receive discounts. Orders of between 25 and 49 flash drives receive a 10% discount, orders of between 50 and 99 flash drives receive a 15% discount, and orders of 100 or more flash drives receive a 20% discount. Write a program that uses the type and quantity of flash drives ordered, and calculates the cost of the order.

Public Function DiskOrderPrice(intQuantity As Integer, strType As String)

Dim intNumOrdered As Integer, strGBSize As String, dbDiscount As Double, intPrice As Double

strGBSize = strType
intNumOrdered = intQuantity

'Get discount rate
If intNumOrdered < 25 Then
dbDiscount = 0
ElseIf intNumOrdered > 25 Then

If intNumOrdered < 50 Then
dbDiscount = 0.1
ElseIf intNumOrdered > 49 Then
If intNumOrdered < 100 Then
dbDiscount = 0.15
Else
dbDiscount = 0.2

End If
End If
End If
'assuming on 8 or 12 GB
If strGBSize = "8 GB" Then
intPrice = 3.3
Else
intPrice = 5.2
End If

discount = ((intNumOrdered * intPrice) * dbDiscount)
DiskOrderPrice = (intNumOrdered * intPrice)
finalPrice = DiskOrderPrice - discount

End Function