This code calculates the price of a sandwich order based on selected toppings and size. Constants define base prices for small and large sandwiches and individual toppings. An if statement checks which toppings checkboxes are selected and adds the corresponding topping price to a running total price variable. Another if/else statement checks the selected radio button for size and adds the small or large base price to the running total, which is then displayed on a label for the user.
This code calculates the price of a sandwich order based on selected toppings and size. Constants define base prices for small and large sandwiches and individual toppings. An if statement checks which toppings checkboxes are selected and adds the corresponding topping price to a running total price variable. Another if/else statement checks the selected radio button for size and adds the small or large base price to the running total, which is then displayed on a label for the user.
This code calculates the price of a sandwich order based on selected toppings and size. Constants define base prices for small and large sandwiches and individual toppings. An if statement checks which toppings checkboxes are selected and adds the corresponding topping price to a running total price variable. Another if/else statement checks the selected radio button for size and adds the small or large base price to the running total, which is then displayed on a label for the user.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnOrder.Click Const Small As Decimal = 2.5 Const Large As Decimal = 4 Const Lettuce As Decimal = 0.1 Const Onion As Decimal = 0.1 Const Tomato As Decimal = 0.25 Const Cheese As Decimal = 0.5 Dim Price As Decimal = 0
If chkLettuce.Checked = True Then
Price += 0.1 End If If chkOnion.Checked = True Then Price += 0.1 End If If chkTomato.Checked = True Then Price += 0.25 End If If chkCheese.Checked = True Then Price += 0.5 End If
If radSmall.Checked Then Price += Small Else Price += Large End If LabelPrice.Text = Price End Sub End Class