This code defines a program that calculates a customer's bill for pizza slices, fries, and drinks. It gets the item quantities from text boxes, calculates the total cost using pre-defined item prices, and displays an itemized bill with quantities, prices, and total in a list. The bill includes the items ordered, price for each item, and a grand total. Input is validated, costs are calculated, and output is formatted for display.
This code defines a program that calculates a customer's bill for pizza slices, fries, and drinks. It gets the item quantities from text boxes, calculates the total cost using pre-defined item prices, and displays an itemized bill with quantities, prices, and total in a list. The bill includes the items ordered, price for each item, and a grand total. Input is validated, costs are calculated, and output is formatted for display.
This code defines a program that calculates a customer's bill for pizza slices, fries, and drinks. It gets the item quantities from text boxes, calculates the total cost using pre-defined item prices, and displays an itemized bill with quantities, prices, and total in a list. The bill includes the items ordered, price for each item, and a grand total. Input is validated, costs are calculated, and output is formatted for display.
Const FRIES_PRICE As Double = 2 Const DRINKS_PRICE As Double = 1.25 Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click 'Compute a customer's bill Dim pizzaSlices As Double, fries As Double, softDrinks As Double lstOutput.Items.Clear() InputData(pizzaSlices, fries, softDrinks) DisplayBill(pizzaSlices, fries, softDrinks) End Sub Sub DisplayBill(ByVal pizzaSlices As Double, ByVal fries As Double, ByVal softDrinks As Double) 'Display an itemized bill Dim total As Double total = TotalCost(pizzaSlices, fries, softDrinks) lstOutput.Items.Add("ITEM" & " " & "QUANTITY" & " " & "PRICE") lstOutput.Items.Add("pizza slices" & " " & pizzaSlices & " " & FormatCurrency(PIZZA_PRICE * pizzaSlices)) lstOutput.Items.Add("fries" & " " & fries & " " & FormatCurrency(FRIES_PRICE * fries)) lstOutput.Items.Add("soft drinks" & " " & softDrinks & " " & FormatCurrency(DRINKS_PRICE * softDrinks)) lstOutput.Items.Add("TOTAL" & " " & FormatCurrency(total)) End Sub Sub InputData(ByRef pizzaSlices As Double, ByRef fries As Double, _ ByRef softDrinks As Double) 'Input items pizzaSlices = CDbl(txtPizza.Text) fries = CDbl(txtFries.Text) softDrinks = CDbl(txtDrinks.Text) End Sub Function TotalCost(ByVal pizzaSlices As Double, ByVal fries As Double, ByVal softDrinks As Double) As Double Return (PIZZA_PRICE * pizzaSlices) + (FRIES_PRICE * fries) + (DRINKS_PRICE * softDrinks) End Function End Class