create an application that will allow the selection of a parts number from a lis
ID: 3637735 • Letter: C
Question
create an application that will allow the selection of a parts number from a list and display the product and the price. It should keep the price of all products a customer wants to purchase, and, once all are selected, calculate the tax and the total charge for the order.Correct the attached code below.
to allow for further expanding of the program the code should be in sub-procedures or functions. Functions and sub procedures must receive values from the calling statement (must have correct passes of values). ALL "calculations" handled in functions. will be five sub procedures and/or functions in this part *** please 'document corrections
*****Please correct and put the calcs into functions (should have 5 functions/sub procedures when finished) with passes of values and document changes.*******
Option Explicit On
Option Strict On
Option Infer Off
Imports System.Convert
Public Class mainForm
Private total As Single = 0
Private Sub mainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'populate the part number listbox with part number values
partNumListbox.Items.Add("AT94")
partNumListbox.Items.Add("BV06")
partNumListbox.Items.Add("CD52")
partNumListbox.Items.Add("DL71")
partNumListbox.Items.Add("DR93")
partNumListbox.Items.Add("DW11")
partNumListbox.Items.Add("FD21")
partNumListbox.Items.Add("KL62")
partNumListbox.Items.Add("KT03")
partNumListbox.Items.Add("KV29")
'populate the product listbox with product values
productListbox.Items.Add("Iron")
productListbox.Items.Add("Home Gym")
productListbox.Items.Add("Microwave Oven")
productListbox.Items.Add("Cordless Drill")
productListbox.Items.Add("Gas Range")
productListbox.Items.Add("Washer")
productListbox.Items.Add("Stand Mixer")
productListbox.Items.Add("Dryer")
productListbox.Items.Add("Dishwasher")
productListbox.Items.Add("Treadmill")
'populate the price listbox with price values
priceListbox.Items.Add("24.95")
priceListbox.Items.Add("794.95")
priceListbox.Items.Add("165.00")
priceListbox.Items.Add("129.95")
priceListbox.Items.Add("495.00")
priceListbox.Items.Add("399.99")
priceListbox.Items.Add("159.95")
priceListbox.Items.Add("349.95")
priceListbox.Items.Add("595.00")
priceListbox.Items.Add("1390.00")
'default the selected index to the first item in each listbox
partNumListbox.SelectedIndex = 0
productListbox.SelectedIndex = 0
priceListbox.SelectedIndex = 0
End Sub
Private Sub exitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitButton.Click
Close()
End Sub
Private Sub resetButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles resetButton.Click
totalChargeLabel.ResetText()
totalLabel.ResetText()
taxLabel.ResetText()
partNumListbox.SelectedIndex = 0
productListbox.SelectedIndex = 0
priceListbox.SelectedIndex = 0
total = 0
End Sub
Private Sub enterButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles enterButton.Click
Const taxRate As Decimal = 0.09D
Dim tax, totalCharge As Single
'get the price for the selected product
total += ToSingle(priceListbox.SelectedItem)
'calculate tax
tax = total * taxRate
'calculate total charge
totalCharge = total + tax
'display results
totalLabel.Text = total.ToString("c2")
taxLabel.Text = tax.ToString("c2")
totalChargeLabel.Text = totalCharge.ToString("c2")
End Sub
Private Sub partNumListbox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles partNumListbox.SelectedIndexChanged
Dim partNumIndex As Integer
'user selects the part number from the part number listbox and the correct product and price
'are automatically selected
partNumIndex = ToInt32(partNumListbox.SelectedIndex)
productListbox.SelectedIndex = partNumIndex
priceListbox.SelectedIndex = partNumIndex
End Sub
Private Sub priceListbox_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles priceListbox.SelectedIndexChanged
End Sub
End Class
Explanation / Answer
ArrayList countDown = new ArrayList(); countDown.Add(5); countDown.Add(4); countDown.Add(3); countDown.Add(2); countDown.Add(1); countDown.Add("blast off!"); countDown.Add(new ArrayList());
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.