Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please answer this question: Programing language Visual Basics . Please provide

ID: 3835906 • Letter: P

Question

Please answer this question: Programing language Visual Basics. Please provide the code to be: (To add one of the items in the list to the shopping cart, then close. Select one item then add then click close. Use module)

Hint: When the user selects either a print book or an audio book, use a module with global variables to hold the name and price of the selected book. That way, the main form will be able to retrieve the name and price after the other forms have closed.

Please design as the following flow chart using modules, and select one item then add then click close.

Question: Design an application that works as shopping cart system. The user should be able to add any of the following items to his or her shopping cart:

Print Books (books on Paper):

I Did It Your Way $11.95

The History of Scotland $14.50

Learn Calculus in One Day $29.95

Feel the Stress $18.50

Audio Books (books on tape):

Learn Calculus in One Day $29.95

The History of Scotland $14.50

The Science of Body Language $12.95

Relaxation Techniques $11.50

The application’s main form should appear similar to the one shown below:

The list box shows all items in the shopping cart. There is a 6% sales tax on the total cost of the items in the shopping cart. Also, for each item in the shopping cart, there is a $2.00 shipping charge. To remove an item from the shopping cart, the user selects it in the list box and clicks the Remove button. The subtotal, tax, shipping, and total fields should be adjusted accordingly. The main form’s menu system is:

When the user selects Rest from the File menu, all items in the shopping cart should be removed, and the subtotal, tax, shipping, and total fields should be cleared. When the user selects Exit from the File menu, the application should end. When the user selects About from the Help menu, a simple About box should appear. When th user selects Print Books from the Products menu, the form below should appear.

To add one of the items in the list to the shopping cart, the user selects it and clicks the Add Book to Cart Button. To cancel the operation, the user simply clicks the Close button without selecting a book. On the main form, when the user selects Audio Books from the Products menu, the form below should appear.

To add one of the items in the list to the shopping cart, the user selects it and clicks the Add Book to Cart button. To cancel the operation, the user simply clicks the Close button without selecting a book.

Show transcribed image text

Label of Subtotal Label of Tax-OS Label of Shipping 0$ Label of Total-OS Main Form (Activated) Counter 0 Subtotal 0 Tax -0 Shipping 0 Add the item to the list ist length Subtotal Subtotal+ Price of item at index counter Shipping shipping +2 Counter Counter 1 Counter List length Tax-subtotal 0.06 Total Shipping Subtotal Label of Subtotal Subtotal Label of Tax-Tax Label of Shipping Shipping Label of Total Total

Explanation / Answer

Form1:

Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lblTax.Text = "0.06%"
lblShipping.Text = "$2/Book"
End Sub

Public Sub lblSubTotal_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lblSubtotal.TextChanged
Const SalesTax As Single = 0.06
Const Shipping As Single = 2.0
Dim TotalSale As Single = 0

lblTax.Text = FormatNumber(lblSubtotal.Text * SalesTax) 'calculate & Display SalesTax

lblShipping.Text = FormatCurrency((lbBooks.Items.Count) * Shipping) 'calculate & Display Shipping

TotalSale = FormatNumber(CSng(lblSubtotal.Text) + CSng(lblTax.Text) + CSng(lblShipping.Text))

lblTotal.Text = FormatCurrency(TotalSale)

End Sub

Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click
'BtnRemove performs one of two tasks:
'1.)Clear selected Item from listBox
'2.)Clear all form Controls
Dim strItem As String = "empty"
strItem = lbBooks.SelectedItem 'Sets strItem to selected item

If strItem = "" Then 'If no Item selected then clear all controls
lbBooks.Items.Clear()
lblSubtotal.Text = 0
lblTax.Text = "0.06%"
lblShipping.Text = "$2/Book"
lblTotal.Text = 0
Else
ReCal(strItem)

lbBooks.Items.Remove(strItem) 'Removes Selected Item from ListBox

'Recalculate the shipping cost after item removal
lblShipping.Text = FormatCurrency((lbBooks.Items.Count) * 2.0)

End If
End Sub

Private Sub ResetToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ResetToolStripMenuItem.Click
'Clear All -- Resets all the form controls to Initial settings
lbBooks.Items.Clear()
lblSubtotal.Text = 0
lblTax.Text = "0.06%"
lblShipping.Text = "$2/Book"
lblTotal.Text = 0

End Sub

//for exit

Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close() 'End the program Run
End Sub

Private Sub PrintBooksToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintBooksToolStripMenuItem.Click
PrintBooks.Show() 'Display the Print Books Select Form
End Sub

Private Sub AudioBooksToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AudioBooksToolStripMenuItem.Click
AudioBooks.Show() 'Display the Audio Books Select Form
End Sub

Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
MessageBox.Show(Me, "Shopping Cart System", "About")
End Sub


End Class

AudioBooks

Public Class AudioBooks
Private Sub AudioBooks_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Loads list of book titles into Audio list box
With lbAudioBooks
.Items.Add("I Did It Your Way " & "(Audio)")
.Items.Add("History of Scotland " & "(Audio)")
.Items.Add("Learn Calculus in one Day " & "(Audio)")
.Items.Add("Relaxation Techniques " & "(Audio)")
End With
End Sub

//when user click on close button the application will be close
Private Sub btnClose_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
Form1.Show()
End Sub

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim strSelect As String = "empty"
Dim strBook As String = "empty"
Dim strMsg As String = "empty"
Dim Price As Single
Dim intX As Integer = 0


Try
strSelect = lbAudioBooks.SelectedItem.ToString
strSelect = strSelect.Substring(0, intX)
GetPrice(strSelect, Price)
Form1.lbBooks.Items.Add(strSelect & " -- " & Price)

Form1.lblSubtotal.Text = FormatNumber(Val(MainForm.lblSubtotal.Text) + Price)

Catch
strMsg = "A Book was Not Selected. "
MessageBox.Show(strMsg, "InValid InPut")

End Try
End Sub
End Class

Print Books
//load the list
Public Class PrintBooks
Private Sub PrintBooks_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Loads list of book titles into Print list Box
With lbPrintBooks
.Items.Add("I Did It Your Way " & "(Print)")
.Items.Add("History of Scotland " & "(Print)")
.Items.Add("Learn Calculus in one Day " & "(Print)")
.Items.Add("Feel the Stress " & "(Print)")
End With
End Sub
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
Form1.Show() 'Returns to shopping cart form
Me.Hide() 'Makes PrintBK form invisible
End Sub

Public Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim strSelect As String = "empty"
Dim strBook As String = "empty"
Dim strMsg As String = "empty"
Dim Price As Single
Dim intX As Integer = 0

'Try ~ Catch code prevents a fault if the Add button is clicked with no book selected.
Try
strSelect = lbPrintBooks.SelectedItem.ToString 'Length Book Title + (Print
strSelect = strSelect.Substring(0, intX)

GetPrice(strSelect, Price)
Form1.lbBooks.Items.Add(strSelect & " -- " & Price)

Form1.lblSubtotal.Text = FormatNumber(Val(MainForm.lblSubtotal.Text) + Price)

Catch
strMsg = "A Book was Not Selected. "
MessageBox.Show(strMsg, "InValid InPut")
End Try
End Sub
End Class

pricing module

Module PriceSelect
Public Sub GetPrice(ByRef Book As String, ByRef BPrice As Single)

Select Case Book
Case "I Did It Your Way"
BPrice = 11.5
Case "History of Scotland"
BPrice = 14.5
Case "Learn Calculus in one Day"
BPrice = 29.95
Case "Feel the Stress"
BPrice = 18.5
Case "Relaxation Techniques"
BPrice = 14.5
Case "The Science of Body Language"
BPrice = 12.95
Case Else
MessageBox.Show("Book Not Found", "InValid Selection")
End Select

End Sub
End Module


recalc module
Module Recalculate
Public Sub ReCal(ByRef strX As String)
Dim sngSubTotal As Single
Dim SPrice As Single
Dim intR
sngSubTotal = MainForm.lblSubtotal.Text
intR = CInt(strX.Length - 5)
SPrice = strX.Substring(intR, 5)

sngSubTotal = sngSubTotal - SPrice


Form1.lblSubtotal.Text = FormatNumber(Val(sngSubTotal))

End Sub
End Module