d number of end zone tickets. Both number of ticket textboxes should contain 0 initially. Your program should display (using a listbox) the name (in firstName(space)lastName format), invoice number, sideline ticket subtotal, endzone ticket subtotal, and total order cost. The subtotals and total should formatted to currency. Tickets prices are set as follows: - Sideline tickets - $35 - End Zone tickets - $15 In addition to the above ticket cost, the fan has to pay a $1.00 service charge per ticket. For each order (each time Calculate Cost
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
Write a program that will take orders for upcoming football game tickets and will let the user know the total
cost of their order.
The fan is to be prompted (using textboxes) to enter their name (in lastName,(space)firstName format), number
of sideline tickets, and number of end zone tickets. Both number of ticket textboxes should contain 0 initially.
Your program should display (using a listbox) the name (in firstName(space)lastName format), invoice number,
sideline ticket subtotal, endzone ticket subtotal, and total order cost. The subtotals and total should formatted to
currency.
Tickets prices are set as follows:
- Sideline tickets - $35
- End Zone tickets - $15
In addition to the above ticket cost, the fan has to pay a $1.00 service charge per ticket.
For each order (each time Calculate Cost is clicked), an invoice number needs to be generated. The format of
this number is:
- First two letters of the first name (Upper Case)
- First two letters of the last name (Upper Case)
- Hyphen (dash/minus) “-“
- Current order number
o (Note: Order number should be set as a class variable. The initial value should be 1000. After
successfully processing an order, the order number should be incremented by 1.)
- Hyphen (dash/minus) “-“
- Total number of tickets
Your program should have three button events. These should perform the following tasks:
- Calculate Cost (perform the calculations and display the output).
- Clear Form (clear the name, reset tickets to 0, clear the listbox, and set the focus to the first textbox).
- Exit (end the program).
*******CORRECT MY CODE WITHOUT USING IF STATEMENTS"*********
Dim name As String
name = txtName.Text
Dim sname As String() = name.Split(" , ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
Dim fname, lname As String
fname = sname(0).ToUpper()
lname = sname(1).ToUpper()
Dim invoice As String
Dim orderNumber As String
invoice = fname(0) + lname(0) + fname(1) + "FB" + Str(orderNumber)
Dim sideline, endzone As Integer
sideline = Convert.ToUInt32(txtSideline.Text)
endzone = Convert.ToUInt32(txtEnd.Text)
Dim sideCost, endCost, finalCost As Double
sideCost = sideline * 20.0
endCost = endzone * 10.0
finalCost = sideCost + endCost + (1.0 * (sideline + endzone))
lstOutput.Items.Add("Customer Name: " + String.Format("{0, 10}", lname(1)) + " " + String.Format("{0,-10}", fname(0)))
lstOutput.Items.Add("Invoice Number: " + String.Format("{0, 10}", invoice))
lstOutput.Items.Add("Sideline Tickets: " + String.Format("{0,10}", " $") + sideCost.ToString("0.00"))
lstOutput.Items.Add("End Zone Tickets: " + String.Format("{0,10}", " $") + endCost.ToString("0.00"))
lstOutput.Items.Add("Total Cost: " + String.Format("{0,20}", " $") + finalCost.ToString("0.00"))
orderNumber = orderNumber + 1
End Sub
Private Sub btnClearForm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
txtSideline.Text = "0"
txtEnd.Text = "0"
txtName.Text = ""
lstOutput.Items.Clear()
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
End Class
- Incorrect Formatting of the Invoice Number
- Incorrect Ticket Price Calculation:
Step by step
Solved in 4 steps with 1 images