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 premiumChannels As Integer = lstPremium.SelectedIndex

        Dim Connections As Integer = lstConnections.SelectedIndex

        Dim totalDue As Decimal



        If radResidential.Checked Then

            totalDue = CalcResidentialTotalDue(premiumChannels)
            lblTotal.Text = totalDue.ToString("C2")
        End If
        If radBusiness.Checked Then

            totalDue = CalcBusinesssTotalDue(premiumChannels, Connections)
            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

        Return ResidentialProcessing + ResidentialBasic + ResidentialPremium * premiumChannels





    End Function

    ' make a function to calculate business customers
    Private Function CalcBusinesssTotalDue(ByVal premiumChannels As Decimal, ByVal connections As Decimal
                                            ) As Decimal

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

        Return BusinessProcessing + BusinessServiceFee + BusinessPremiumchannelsCharge * premiumChannels




    End Function

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.

This question has already been answered. Start a new discussion instead.