我想弄清楚我们要收多少钱。我们所处理的公司正在使用分层定价策略,根据我们储存设备的天数来收取更多的费用。
分级金额如下:第1-4天= $100,第5-8天= $150,日9+ = $200。我需要计算每天的金额。所以,如果租金是3天,我需要计算3天,按100/天=300美元计算。如果租房时间是8天,那么我需要计算前4天的总租金为400美元+接下来的4天,每个150天= 600美元,总计1000美元。
我有几天的数字。我怎样才能从租用天数中获得总成本?
发布于 2016-11-22 15:24:46
下面将提示输入,并返回一个带有答案的消息框。此外,你说8天应该返回850,但你的意思是1000?如果不让我知道,我会更新的。
Sub calculateCost()
Dim intDays As Variant
Dim dblCost As Double
intDays = InputBox("Please type in number of days")
If Not IsNumeric(intDays) Then
MsgBox "Please type only numbers"
Exit Sub
End If
Select Case intDays
Case 1, 2, 3, 4
dblCost = intDays * 100
Case 5, 6, 7, 8
dblCost = 400 + (intDays - 4) * 150
Case Is > 8
dblCost = 1000 + (intDays - 8) * 200
Case Else
dblCost = 0
End Select
MsgBox "Total cost is " & dblCost
End Sub
https://stackoverflow.com/questions/40745434
复制相似问题