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

Public Class frmInvoiceTotal Private Sub btnCalculate_Click(sender As Object, e

ID: 3603125 • Letter: P

Question

Public Class frmInvoiceTotal
Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click


'Dim subtotal As Decimal = CDec(txtSubtotal.Text)


Dim subtotal As Decimal = Decimal.Parse(txtSubtotal.Text)


Dim discountPercent As Decimal

If subtotal >= 500 Then
discountPercent = 0.2D
ElseIf subtotal >= 250 And Subtotal < 500 Then
discountPercent = 0.15D
ElseIf subtotal >= 100 And Subtotal < 250 Then
discountPercent = 0.1D
Else
discountPercent = 0
End If

Dim discountAmount As Decimal = subtotal * discountPercent

Dim invoiceTotal As Decimal = subtotal - discountAmount


'txtDiscountPercent.Text = FormatPercent(discountPercent, 2)


txtDiscountAmount.Text = FormatCurrency(discountAmount, 2)



txtTotal.Text = FormatCurrency(invoiceTotal, 2)

txtDiscountPercent.Text = discountPercent.ToString("p2")
txtDiscountAmount.Text = discountAmount.ToString("c2")
txtTotal.Text = invoiceTotal.ToString("c2")


txtSubtotal.Select()
End Sub

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Me.Close()
End Sub
End Class

In visual Studio, In this code,

Explain the CDec function,

Dim subtotal As Decimal = CDec(txtSubtotal.Text)

and

the Decimal Parse method

Dim subtotal As Decimal = Decimal.Parse(txtSubtotal.Text)

comment to explain the statement Discount Percent, discountAmount and invoicetotal format as following:

txtDiscountPercent.Text = FormatPercent(discountPercent, 2)

txtDiscountAmount.Text = FormatCurrency(discountAmount, 2)

txtTotal.Text = FormatCurrency(invoiceTotal, 2)

And comment to explain the ToString method for discountPercent, discountAmount and invoiceTotal.

txtDiscountPercent.Text = discountPercent.ToString("p2")
txtDiscountAmount.Text = discountAmount.ToString("c2")
txtTotal.Text = invoiceTotal.ToString("c2")

Explain those statements which are in this code. Do not give general statement, Stay in the code and explain it as a statement in this code Please.

Explanation / Answer


'Dim subtotal As Decimal = CDec(txtSubtotal.Text)


Dim subtotal As Decimal = Decimal.Parse(txtSubtotal.Text)


Dim discountPercent As Decimal

If subtotal >= 500 Then
discountPercent = 0.2D
ElseIf subtotal >= 250 And Subtotal < 500 Then
discountPercent = 0.15D
ElseIf subtotal >= 100 And Subtotal < 250 Then
discountPercent = 0.1D
Else
discountPercent = 0
End If

Dim discountAmount As Decimal = subtotal * discountPercent

Dim invoiceTotal As Decimal = subtotal - discountAmount


'txtDiscountPercent.Text = FormatPercent(discountPercent, 2)


txtDiscountAmount.Text = FormatCurrency(discountAmount, 2)



txtTotal.Text = FormatCurrency(invoiceTotal, 2)

txtDiscountPercent.Text = discountPercent.ToString("p2")
txtDiscountAmount.Text = discountAmount.ToString("c2")
txtTotal.Text = invoiceTotal.ToString("c2")


txtSubtotal.Select()
End Sub

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Me.Close()
End Sub
End Class

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote