views:

203

answers:

2

The program should request the person’s occupation, the amount of the bill, and the percentage tip as input and pass this information to a Sub procedure to display the person and the tip. Title is gratuities, first line Person’s occupation, amount of the bill:, Percentage tip: Compute Tip, and show the tip. Im not sure how to approach it properly. Any help is greatly appreciated.

Public Class Form1

Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As _
    System.EventArgs) Handles btnCompute.Click

    Dim Occupation As String = CStr(txtOccupation.Text)
    Dim Bill As Double = CDbl(txtBill.Text)
    Dim Tip As Double = CDbl(txtTip.Text)

    lstOuput.Text = 'hmmmmm.....'



End Sub

End Class

+1  A: 
lstOutput.Text = Bill * (1 + If(Tip<1,Tip,Tip/100))
Joel Coehoorn
It says "Expression Expected" for If
Davey
What version of vb.net? This requires VS2008. VS2005 would need IIF() instead.
Joel Coehoorn
A: 

Since you have assigned the Bill and Tip to double variables, you can assign the gratuity amount into another variable, or output it directly.

Dim Gratuity as Double = Bill * Tip

lstOutput.text = "Total Bill + Gratuity = " & string.format(Bill + Gratuity, "c")
TheTXI