basicServiceFee允许10个免费连接,价格为80美元
每当连接大于10时,每个附加连接都是4美元加上基本连接
我如何添加4美元的费用,并在选择connectionsListBox中的每个数字时继续添加.
我的代码添加了前4美元的费用,然后在connectionsListBox上的11之后停止.我如何得到12另外4美元和13另外4美元
这是我的代码:
Private Function businessTotalCharges(ByVal processingFee As Double, ByVal basicServiceFee As Double,
ByVal premiumChannelFee As Double, ByVal connections As Double) As Double
Dim total As Double
Dim perchannel As Double
Dim totalChannelFee As Double
Dim connectionsPrice As Double
Dim perConnection As Double
processingFee = 16.5
basicServiceFee = 80
perchannel = CDbl(premiumListBox.SelectedItem) * 50
connections = CDbl(connectionsListBox.SelectedItem)
premiumChannelFee = (CDbl(premiumListBox.SelectedItem))
If connections > 10 Then
connectionsPrice = basicServiceFee + 4
End If
If connections <= 10 Then
connectionsPrice = basicServiceFee
End If
If premiumChannelFee > 0 Then
totalChannelFee = perchannel + connectionsPrice
End If
total = totalChannelFee + processingFee
totalLabel.Text = total.ToString("C2")
Return total
End Function
Private Sub calcButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calcButton.Click
Dim procFee As Double
Dim basicFee As Double
Dim channelFee As Double
Dim connectionNum As Double
If residentialRadioButton.Checked = True Then
Call residentialTotalCharges(procFee, basicFee, channelFee)
End If
If businessRadioButton.Checked = True Then
Call businessTotalCharges(procFee, basicFee, channelFee, connectionNum)
End If
End Sub
End Class
Run Code Online (Sandbox Code Playgroud)
简单的数学:
connectionsPrice = basicServiceFee + 4 * (connections - 10)
Run Code Online (Sandbox Code Playgroud)