1.11M Members

hey guys i need some help on my code here..........

im trying to do some computation about the biling system or a library if the borrwer returns the book on time it will be no charge.......but if hte book is damage then it will charge him trice the ammount of the fineRate also if hes a non member theres an extra charge for it 30% of the FineRate

``````        Dim FineRate As String = My.Settings.FineRate
Dim dmgfee As Double
Dim tot As String
Dim dayslate As String
Dim nm As Double
Dim fac As String
Dim dt1 As Date
Dim dt2 As Date
Dim ef As String
Dim ts As System.TimeSpan

dt1 = DateTimePicker3.Value
dt2 = DateTimePicker4.Value
ts = dt2.Subtract(dt1)

dayslate = ts.Days

If dayslate >= 0 Then
lblDaysLate.Text = dayslate
End If

dayslate = Val(lblDaysLate.Text)

If cboBookStat.Text = "Damage" Then
dmgfee = 0.3 * FineRate
ElseIf cboBookStat.Text = "Un Damage" Then
dmgfee = 0 * FineRate
End If

If lblbtype.Text = "Non Member" Then
nm = 0.3 * FineRate
ElseIf lblbtype.Text = "Member" Then
nm = 0.1 * FineRate
End If

fac = dayslate * FineRate

ef = dmgfee + nm

tot = FineRate * (dayslate + ef)

lblDmgFee.Text = dmgfee
lblTotal.Text = tot
lblTfine.Text = fac
``````

Should we guess what's wrong with it?
Here I go:

1. Declare FineRate as double, string won't do. Also change it in My.settings
2. You calculate daylate, assign it's value to a label and then assign it the value of the label. Can you please explain why you are re-assigning it the same value?
3. In the description you mention if the book is damaged they the customer has to pay trice the amount of FineRate. Does trice mean 3 times or 30% ?
4. If the customer is not a member then you add 30%, like you've specified in the description, but if he is a member then you add 10% (?).
5. You need to reconsider what you are doing in lines 44 and beyond. Fac isn't used -although it should - and you are calculating total like this:
`tot = FineRate * (dayslate + (damaged_category * FineRate))`
Either change it to `tot = fac + ef` or `tot = (FineRate * dayslate) + ef` or change dmgfee and nm to hold only the multiplier for the FineRate. Both doesn't make sense.

Those addins are only applied if the returned book is late.......

FineRate 30

DmgFee:

Members 2 * 30

Non Members 3 * 30

LateFee:

Members dayslate * 30

Non Members dayslate * 30 + 30% of the finerate

if its a member then it there will be no addins as long as the book isnt damaged...inshort only addin fee for members are dmgfee

the damage fee for the book for members are only Times 2 of the FineRate

if its a non member and it is late....it i will charge additional 30% fee for the FineRate
also if its Damage it will add another chrage which is Trice the value of FineRate.