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 each checkbox to add topping prices to a running total price variable. The total is further adjusted based on whether the small or large radio button is selected, and the final price is displayed on a label.
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 each checkbox to add topping prices to a running total price variable. The total is further adjusted based on whether the small or large radio button is selected, and the final price is displayed on a label.
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 each checkbox to add topping prices to a running total price variable. The total is further adjusted based on whether the small or large radio button is selected, and the final price is displayed on a label.
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