I am trying to calculate a cable bill for a residential and business customer can someone point me in the right direction for my logic?For residential customers it is 4.50 processing fee,30 basic service fee and 5 per channel. For business customers processing fee = 16.50 basicservice fee is 80 for the first 10 connections if connections greater than 10 then its 4 for each additional and 50 per channel when I hit calculate no matter how many connections or channels I choose for each category it gives me the same output which means my logic must be wrong can anyone make a suggestion?

``````Option Strict On

Public Class Main
Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
If Data_Validated_ok() = False Then Exit Sub

Dim Connections As Integer = lstConnections.SelectedIndex

Dim totalDue As Decimal

lblTotal.Text = totalDue.ToString("C2")
End If

lblTotal.Text = totalDue.ToString("C2")
End If

End Sub

' make a function to calculate residential customers

Private Function CalcResidentialTotalDue(ByVal premiumChannels As Decimal) As Decimal

Const ResidentialProcessing As Decimal = 4.5D
Const ResidentialBasic As Integer = 30
Const ResidentialPremium As Integer = 5

End Function

' make a function to calculate business customers
) As Decimal

Const BusinessProcessing As Decimal = CDec(16.5)
Const BusinessServiceFee As Integer = 80

End Function
``````
3
Contributors
2
Replies
15
Views
3 Years
Discussion Span
Last Post by Reverend Jim

I dont see an If statement that will determine if there more that 10 connections.

Try

``````If radResidential.Checked Then
totalDue = 4.5 + 30 + 5 * premiumChannels
Else
totalDue = 16.50 + 80 + 4 * Math.Max(premiumChannels - 10, 0)
End If
``````

Math.Max returns the maximum of the two values. If the number of channels is 10 or fewer it return 0, otherwise it returns the number of channels over 10.