Option Explicit ' calculate travelling fare based on fare type ' and travel information Sub TaxiCalculation() ' Data values must be consistent wwith data in B2 and B3 Const PricePerKm As Double = 1.5 Const PricePerMinute As Double = 0.55 Dim typeAnswer As String Dim userInput As String Dim negotiatedFare As Double Dim distance As Double Dim waitMinutes As Double Dim total As Double ' get the fare type first typeAnswer = InputBox("Enter U to negotiate fare or T for meter reading") If typeAnswer <> "U" And typeAnswer <> "T" Then MsgBox "Invalid user input" Exit Sub End If ' type answer must be either U or T If typeAnswer = "U" Then ' uber style userInput = InputBox("Enter negotiated fare:") If IsNumeric(userInput) Then negotiatedFare = CDbl(userInput) total = negotiatedFare Else MsgBox "Wrong input type" Exit Sub End If Else ' not U, then it must be traditional taxi style ' get valid travelling distance data userInput = InputBox("Enter distance travelled:") If IsNumeric(userInput) Then distance = CDbl(userInput) Else MsgBox "Invalid user input type" Exit Sub End If ' get valid idling minutes userInput = InputBox("Enter waiting minutes:") If IsNumeric(userInput) Then waitMinutes = CDbl(userInput) Else MsgBox "Invalid user input type" Exit Sub End If ' calculate fare total = distance * PricePerKm + waitMinutes * PricePerMinute End If Dim row As Integer row = Cells(1, "H") ' output result based on the style choice If typeAnswer = "U" Then Cells(row, "A") = "Uber" Cells(row, "B") = negotiatedFare Cells(row, "C") = "N/A" Cells(row, "D") = "N/A" Cells(row, "E") = total MsgBox "Your total fare from your negotiation is $" & total Else Cells(row, "A") = "Taxi" Cells(row, "B") = "N/A" Cells(row, "C") = distance Cells(row, "D") = waitMinutes Cells(row, "E") = total MsgBox "Your total fare based on meter reading is $" & total End If Cells(1, "H") = row + 1 End Sub