dcsimg
Results 1 to 4 of 4

Thread: Problem with school project

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2017
    Posts
    2

    Problem with school project

    Hi I am new to this forum. I missed some class last week due to my wife and baby being sick. I turned in a wage calculator project and my instructor said I got the math for calculating the overtime right, but its not calculating the tax for the overtime. I have looked everywhere in my book and I cant for the life of mee see what I am missing
    Attached Files Attached Files

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    40,118

    Re: Problem with school project

    Welcome to VBForums

    Thread moved from the 'Chit-chat' forum (for non-technical chat) to the 'VB.Net' (VB2002 and later) forum

    To make it easier for people to help, here is the contents of the attached file:
    Code:
    ' Program Name: Payroll Calculator
    ' Author:       Chad Hakala
    ' Date:         12/5/2017
    ' Purpose:      Calculates and displays payroll information 
    Public Class frmPayRollCalculator
        Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
            ' Declarations 
            Dim decEnterHours As Decimal
            Dim decEnterPay As Decimal
            Dim decGross As Decimal
            Dim decTax As Decimal
            Dim decSingle As Decimal = 0.19
            Dim decFamily As Decimal = 0.16
            ' This line text the textboxs to see if they are numeric
            If IsNumeric(txtEnterPay.Text) And IsNumeric(txtEnterHours.Text) Then
                decEnterHours = Convert.ToDecimal(txtEnterHours.Text)
                decEnterPay = Convert.ToDecimal(txtEnterPay.Text)
                ' this line calculates the users gross pay, net pay and taxes.
                ' Displays a msg box if the values entered are not rigth.
                If decEnterPay <= 40.0 And decEnterPay >= 8.0 Then
    
                    If decEnterHours >= 5 And decEnterHours <= 60 Then
    
                        If decEnterHours <= 40 Then
                            If radSingle.Checked Then
                                decGross = decEnterHours * decEnterPay
                                decTax = decGross * decSingle
    
                            ElseIf radFamily.Checked Then
                                decGross = decEnterHours * decEnterPay
                                decTax = decGross * decFamily
                            End If
                        End If
                        If decEnterHours > 40 Then
                            If radSingle.Checked Then
    
                                decGross = 40 * decEnterHours
                                decTax = decGross * decSingle
    
                            ElseIf radFamily.Checked Then
    
                                decGross = 40 * decEnterPay
                                decTax = decGross * decFamily
                            End If
                            decGross += (decEnterHours - 40) * (decEnterPay * 1.5)
    
                        End If
                    Else
                        MsgBox("Hours must be greater than 5 or less than 60 ")
                        radFamily.Checked = False
                        radSingle.Checked = False
                        lblDisplayGross.Text = ""
                        lblDisplayNet.Text = ""
                        lblDisplayName.Text = ""
                        txtEnterHours.Clear()
                        txtEnterPay.Clear()
                        txtEnterName.Clear()
                        txtEnterName.Focus()
                    End If
    
                Else
                    MsgBox("pay must be under 40 and above 8")
                    radFamily.Checked = False
                    radSingle.Checked = False
                    lblDisplayGross.Text = ""
                    lblDisplayNet.Text = ""
                    lblDisplayName.Text = ""
                    txtEnterHours.Clear()
                    txtEnterPay.Clear()
                    txtEnterName.Clear()
                    txtEnterName.Focus()
    
                End If
            Else
                MsgBox("Please Enter a numeric value ")
                radFamily.Checked = False
                radSingle.Checked = False
                lblDisplayGross.Text = ""
                lblDisplayNet.Text = ""
                lblDisplayName.Text = ""
                txtEnterHours.Clear()
                txtEnterPay.Clear()
                txtEnterName.Clear()
                txtEnterName.Focus()
    
            End If
    
    
    
            lblDisplayGross.Text = decGross.ToString("C")
            lblDisplayTax.Text = decTax.ToString("C")
            lblDisplayNet.Text = (decGross - decTax).ToString("C")
            lblDisplayName.Text = txtEnterName.Text
        End Sub
    
        Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
    
            ' Clears the program 
            txtEnterName.Clear()
            txtEnterHours.Clear()
            txtEnterPay.Clear()
            lblDisplayGross.Text = ""
            lblDisplayNet.Text = ""
            lblDisplayName.Text = ""
            lblDisplayTax.Text = ""
            txtEnterName.Focus()
            radSingle.Focus()
    
        End Sub
    End Class

  3. #3
    Hyperactive Member
    Join Date
    Nov 2017
    Posts
    399

    Re: Problem with school project

    Quote Originally Posted by picklerick View Post
    Hi I am new to this forum. I missed some class last week due to my wife and baby being sick. I turned in a wage calculator project and my instructor said I got the math for calculating the overtime right, but its not calculating the tax for the overtime. I have looked everywhere in my book and I cant for the life of mee see what I am missing
    Code:
                        If decEnterHours > 40 Then
                            If radSingle.Checked Then
    
                                decGross = 40 * decEnterHours
                                decTax = decGross * decSingle
    
                            ElseIf radFamily.Checked Then
    
                                decGross = 40 * decEnterPay
                                decTax = decGross * decFamily
                            End If
                            decGross += (decEnterHours - 40) * (decEnterPay * 1.5)
    
                        End If
    At first glance, I'm pretty sure the problem is you are calculating the final Overtime Gross pay after you've calculated the Tax. I believe you just need to move the bolded statement above the "If radSingle.Checked..." line.

    Edit: You'll need to make more changes than just moving that line, you'll need to change it so that in that one line the Gross Pay is fully calculated, and then inside the radFamily/radSingle if statements there should be no recalculations of gross pay.
    Last edited by OptionBase1; Dec 17th, 2017 at 05:09 PM.

  4. #4

    Thread Starter
    New Member
    Join Date
    Dec 2017
    Posts
    2

    Re: Problem with school project

    Got it! Thank you very much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width