第一题:
Private Sub Form_Click()
Dim x As Double, Y As Double
x = InputBox("请输入当前顾客购买鸡蛋的重量(以公斤为单位)")
If x < 3 Then
Y = 7.6 * x
Else
Y = 7.6 * x * 0.8
End If
Print Format(Y, "0.00")
End Sub
第二题:
Private Sub Form_Click()
Dim x As Double, Y As Double
x = InputBox("请输入顾客所乘的公里数")
If x / Fix(x) = 1 Then
x = x
Else
x = Fix(x) + 1
End If
If x > 15 Then
Y = 7 + 13 * 1.5 + (x - 15) * 2.1
ElseIf x > 2 Then
Y = 7 + (x - 2) * 1.5
Else
Y = 7
End If
Print Y
End Sub
既然超简单,自己做好了。