1 Replies - 653 Views - Last Post: 28 November 2013 - 11:34 PM Rate Topic: -----

#1 glb482417  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 28-November 13

how to calculate sales tax and amount due.

Posted 28 November 2013 - 11:06 PM

Iam trying to calculate a sales tax and amount due i am stuck. Ihave a pizza order form to get the sales tax you have (toppingsDecimal + pizzaDecimal - DiscountDecimal)* SalesTax_Rate_Decimal you have two discount oppitions 10% and 15% to choose from how can i do this where is my code wrong it calculates the 15% discount but not the 10% discount please help if you can. I am using Visual Basic 2010

Public Class MamaJanesForm
    ' Declare a named constant.
    Const Peppers_Charge_Decimal As Decimal = 0.75D
    Const Onions_Charge_Decimal As Decimal = 0.75D
    Const ExtraCheese_Charge_Decimal As Decimal = 0.75D
    Const Coupon_Rate_Decimal As Decimal = 0.1D
    Const PreferredCustomer_Rate_Decimal As Decimal = 0.15D
    Const SalesTax_Rate_Decimal As Decimal = 0.08D
    Dim ToppingsDecimal, DiscountDecimal, PizzaDecimal, SalestaxDecimal As Decimal
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub FontToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FontToolStripMenuItem.Click
        ' Change the font name for the label.
        With FontDialog1
            AmountDueLabel.Font = .Font
        End With
    End Sub

    Private Sub ColorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ColorToolStripMenuItem.Click
        ' Change the color of the amount due label.
        With ColorDialog1
            AmountDueLabel.ForeColor = .Color
        End With
    End Sub

    Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
        Dim MessageString As String
        ' Display the message box.
        MessageString = "Mama Jane's Pizza" & Environment.NewLine & "Programmed by Gary Brewster"
        MessageBox.Show(MessageString, "About Mama Jane's Pizza", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub

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

    Private Sub CalculateToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculateToolStripMenuItem.Click
        Dim ToppingsDecimal, DiscountDecimal, PizzaDecimal, SalestaxDecimal, AmountDueDecimal As Decimal
        ' Look up pizza rate.
        Dim SizeIndexInteger As Integer
        Dim StyleIndexInteger As Integer
        Dim pizzaArrayDecimal(,) As Decimal = {{5.99, 6.99, 7.99, 8.99}, _
                                  {6.99, 7.99, 8.99, 9.99}}

        SizeIndexInteger = SizeComboBox.SelectedIndex
        StyleIndexInteger = StyleComboBox.SelectedIndex
        If SizeIndexInteger <> -1 And StyleIndexInteger <> -1 Then
            PizzaTextBox.Text = pizzaArrayDecimal(SizeIndexInteger, StyleIndexInteger).ToString
        End If
        'Include the Toppings charges.
        If CheckBox1.Checked Then
            ToppingsDecimal += Peppers_Charge_Decimal
        End If
        If CheckBox2.Checked Then
            ToppingsDecimal += Onions_Charge_Decimal
        End If
        If CheckBox3.Checked Then
            ToppingsDecimal += ExtraCheese_Charge_Decimal
        End If
        If RadioButton2.Checked Then
            PizzaDecimal = PizzaTextBox.Text
            DiscountDecimal = Coupon_Rate_Decimal * (PizzaDecimal + ToppingsDecimal)

        ElseIf RadioButton3.Checked Then

            PizzaDecimal = PizzaTextBox.Text
            DiscountDecimal = PreferredCustomer_Rate_Decimal * (PizzaDecimal + ToppingsDecimal)
                'Calculate sales tax
                SalestaxDecimal = ((ToppingsDecimal + PizzaDecimal) - DiscountDecimal) * SalesTax_Rate_Decimal
            End Try
            ' Find the total.
            AmountDueDecimal = ToppingsDecimal + PizzaDecimal + DiscountDecimal + SalestaxDecimal

        End If
        'Display amounts in labels
        ToppingsTextBox.Text = ToppingsDecimal.ToString("C")
        DiscountTextBox.Text = DiscountDecimal.ToString("C")
        SalesTaxTextBox.Text = SalestaxDecimal.ToString("C")
        PizzaTextBox.Text = PizzaDecimal.ToString("C")

    End Sub
    Private Sub ClearToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearToolStripMenuItem.Click
        ' Clear all information.
        CheckBox1.Checked = False
        CheckBox2.Checked = False
        CheckBox3.Checked = False
        RadioButton1.Checked = False
        RadioButton2.Checked = False
        RadioButton3.Checked = False
        SizeComboBox.SelectedIndex = -1
        StyleComboBox.SelectedIndex = -1
    End Sub

End Class

Is This A Good Question/Topic? 0
  • +

Replies To: how to calculate sales tax and amount due.

#2 astonecipher  Icon User is offline

  • Major DIC Head
  • member icon

Reputation: 256
  • View blog
  • Posts: 1,296
  • Joined: 03-December 12

Re: how to calculate sales tax and amount due.

Posted 28 November 2013 - 11:34 PM


RadioButton2.Checked = true

And your try statement is of no value to you without something in the catch block.

It would also behoove you to name your controls so that you know what they correspond to, you do it for your variables but not all of your controls.

This post has been edited by astonecipher: 28 November 2013 - 11:37 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1