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

This is my code for Visual Basic 2012 Chapter 7 on the Kenton case project, I am

ID: 664284 • Letter: T

Question

This is my code for Visual Basic 2012 Chapter 7 on the Kenton case project, I am not sure how to make the stores show 3 seperate values instead of showing the same value for all 3 when I test it and I also need the 3 store values to be the Double format.

Public Class MainForm

    Private Sub calculateButton_Click(sender As Object, e As EventArgs) Handles calculateButton.Click

  
        Dim inputPayroll As String
        Dim payrollAmount As Double
        Dim streAccumulator1 As Double
        Dim streAccumulator2 As Double
        Dim streAccumulator3 As Double
        Dim companyAccumulator As Double

        'clear the storeLabel and companyLabel

        storeLabel1.Text = String.Empty
        storeLabel2.Text = String.Empty
        storeLabel3.Text = String.Empty
        compLabel.Text = String.Empty

        For stores As Integer = 1 To 3
            For payroll As Integer = 1 To 5
                inputPayroll = InputBox("Payroll Amounts" &
                payroll.ToString, "Store " &
                stores.ToString)
                Decimal.TryParse(inputPayroll, payrollAmount)

                'add payroll to store total

                streAccumulator1 += payrollAmount
                streAccumulator2 += payrollAmount
                streAccumulator3 += payrollAmount

            Next payroll

            'add store payroll to company total

            companyAccumulator += streAccumulator1

            'display store payroll


            storeLabel1.Text =
            streAccumulator1.ToString("N2") & ControlChars.NewLine
            storeLabel2.Text =
            streAccumulator2.ToString("N2") & ControlChars.NewLine
            storeLabel3.Text =
            streAccumulator3.ToString("N2") & ControlChars.NewLine


            'reset payroll for next store

            streAccumulator1 = 0
            streAccumulator2 = 0
            streAccumulator3 = 0

        Next stores

        'display company payroll

        compLabel.Text =
        companyAccumulator.ToString("C2")

    End Sub

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

Explanation / Answer

take the input 3 times from the user.

change this part of the code from

inputPayroll = InputBox("Payroll Amounts" &
                payroll.ToString, "Store " &
                stores.ToString)
                Decimal.TryParse(inputPayroll, payrollAmount)

                'add payroll to store total

                streAccumulator1 += payrollAmount
                streAccumulator2 += payrollAmount
                streAccumulator3 += payrollAmount

to

inputPayroll = InputBox("Payroll Amounts" &
                payroll.ToString, "Store " &
                stores.ToString)
                Decimal.TryParse(inputPayroll, payrollAmount)

                'add payroll to store total

                streAccumulator1 += payrollAmount

inputPayroll = InputBox("Payroll Amounts" &
                payroll.ToString, "Store " &
                stores.ToString)
                Decimal.TryParse(inputPayroll, payrollAmount)
                streAccumulator2 += payrollAmount

inputPayroll = InputBox("Payroll Amounts" &
                payroll.ToString, "Store " &
                stores.ToString)
                Decimal.TryParse(inputPayroll, payrollAmount)
                streAccumulator3 += payrollAmount

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