\"border: 0px; height: 0px; margin: 0px; padding: 0px; width: 707px\"> Strugglin
ID: 3535629 • Letter: #
Question
"border: 0px; height: 0px; margin: 0px; padding: 0px; width: 707px">
Struggling to finish the code. Here is the problem:
The Doughnut Shoppe sells four varieties of doughnuts:
Glazed
($.65), Sugar ($.65), Chocolate ($.85), and Filled ($1.00). It
also
sells regular coffee ($1.80) and cappuccino ($2.50). The
store
manager wants an application that she can use to calculate
and
display a customer's subtotal, 3% sales tax, and total due.
Create the interface shown in Figure 17-16. Code the
application.
"text-decoration:underline;background-color:rgb(136,136,136);">
Use one function
to
calculate and return the cost of the doughnut.Use another
function
to calculate and return the cost of the coffee. Use a third
function to calculate and return the 3% sales tax. Use a Sub
procedure to clear the subtotal, sales tax, and total due
amounts
when a radio button is clicked
.
Code I have so far:
Public Class frmMain
Private Sub btnExit_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Me.Close()
End Sub
Private Sub decSubtotal_KeyPress(ByVal sender As Object, ByVal e
As System.Windows.Forms.KeyPressEventArgs) Handles
btnCalculate.KeyPress
' allows the text box to accept numbers, the period, and the
backspace key
If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso
e.KeyChar <> "." AndAlso e.KeyChar <> ControlChars.Back
Then
e.Handled = True
End If
End Sub
Private Sub Emptylabels()
' removes the contents from the labels that display subtotal,
tax, and total due
lblSubtotal.Text = String.Empty
lblSalestax.Text = String.Empty
lblTotal.Text = String.Empty
End Sub
Private Function btnCalculate_Click(ByVal sender As Object,
ByVal e As System.EventArgs) Handles btnCalculate.Click
' displays the total price of doughnuts and coffee
selections
Dim intPrice As Decimal
Dim decSubtotal As Decimal
Dim decSalestax As Decimal
Dim decTotal As Decimal
' calculates the cost of doughnuts
If btnGlazed.Checked = True Then
Â
Â
intPrice = 0.65
Â
End If
If btnSugar.Checked = True Then
Â
Â
intPrice = 0.65
Â
End If
If btnChoco.Checked = True Then
Â
Â
intPrice = 0.85
Â
End If
If btnFilled.Checked = True Then
Â
Â
intPrice = 1.0
Â
End If
' calculates any additional cost for coffee
If btnNone.Checked = True Then
Â
Â
decSubtotal = intPrice + 0.0
Â
End If
If btnReg.Checked = True Then
Â
Â
decSubtotal = intPrice + 1.8
Â
End If
If btnCapp.Checked = True Then
Â
Â
decSubtotal = intPrice + 2.5
Â
Else
MessageBox.Show("Please choose Doughnut and Coffee", _
"The Doughnut Shoppe", MessageBoxButtons.OK,
MessageBoxIcon.Information)
End If
' determine the price of a doughnut with coffee
lblSubtotal.Text = decSubtotal.ToString("C0")
lblSalestax.Text = decSalestax.ToString("C0")
lblTotal.Text = decTotal.ToString("C0")
' assign doughnut selected with coffee
Decimal.TryParse(intPrice, lblSubtotal.Text)
Decimal.TryParse(decSalestax, decSalestax)
Decimal.TryParse(decTotal, decTotal)
' Calculate subtotal
Â
lblSubtotal.Text = intPrice + 0.0
lblSubtotal.Text = intPrice + 1.8
lblSubtotal.Text = intPrice + 2.5
Â
' Calculate sales tax.
decSalestax = Math.Round(0.03, 2) * decSubtotal
' Show sales tax
lblSalestax.Text = decSalestax.ToString("C2")
' Show subtotal for doughnut and coffee selection
lblSubtotal.Text = decSubtotal.ToString("C2")
' Calculate total due
Â
Â
lblTotal.Text = decSubtotal + decSalestax
Â
End Function
End Class
Explanation / Answer
Your is fine but some errors , you must initialize intPrice =0 and then when you are add the values to intPrice then do this intPrice +=0.65 ,,,,,,,,,,etc like that....It will work
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.