# Thread: Problem with school project

1. ## 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

2. ## 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
' 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
decGross = decEnterHours * decEnterPay
decTax = decGross * decSingle

decGross = decEnterHours * decEnterPay
decTax = decGross * decFamily
End If
End If
If decEnterHours > 40 Then

decGross = 40 * decEnterHours
decTax = decGross * decSingle

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 ")
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")
lblDisplayGross.Text = ""
lblDisplayNet.Text = ""
lblDisplayName.Text = ""
txtEnterHours.Clear()
txtEnterPay.Clear()
txtEnterName.Clear()
txtEnterName.Focus()

End If
Else
MsgBox("Please Enter a numeric value ")
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()

End Sub
End Class```

3. ## Re: Problem with school project

Originally Posted by picklerick
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

decGross = 40 * decEnterHours
decTax = decGross * decSingle

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.

4. ## 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