I'll be blunt. I'm taking a class on VB.NET and I have very little idea what I'm doing in this program, just yet. The problem is in here... somewhere. The assignment is to code a simple form that takes the hours a person's worked and the number of their fictional dependents, mix them up with a few constants, and spit out the person's paycheck, post-tax.
Problem being, I can't seem to get it to actually output the results of any calculations.
Pardon what I think is incredibly clumsy coding. Still wrapping my head around typing, but I guess that could be the root of my problem. Perhaps I should stop guessing, since so far those guesses haven't led to a solution. Anyway-- the output winds up as 0.00 instead of the actual solution to the formula. Any suggestions or explanation would be appreciated.
Problem being, I can't seem to get it to actually output the results of any calculations.
Pardon what I think is incredibly clumsy coding. Still wrapping my head around typing, but I guess that could be the root of my problem. Perhaps I should stop guessing, since so far those guesses haven't led to a solution. Anyway-- the output winds up as 0.00 instead of the actual solution to the formula. Any suggestions or explanation would be appreciated.
VB.NET:
'Constant section Lab #2 CS 115
Const FED_TAX As Decimal = CDec(0.2) '20% Federal Tax
Const STATE_TAX As Decimal = CDec(0.032) '3.2% State Tax
Const DEPENDENTS As Decimal = CDec(48.6) 'Deduction for dependents
Const HOURLY_RATE As Decimal = 28 'Rate per hour
'Declaration section
Dim strName As String 'Name of employee
Dim decDependents As Decimal 'Number of dependents
Dim decHours As Decimal 'Hours worked
Dim decGross As Decimal 'Gross pay
Dim decFedTax As Decimal 'Federal tax
Dim decStateTax As Decimal 'State tax
Dim decTax As Decimal 'Total taxes
Dim decNetPay As Decimal 'Net pay
Dim decFactor As Decimal = 1 'number of paychecks per month
If decHours > 40 Then 'Branches formula based on overtime
'If >40, overtime pay
decGross = CDec(40 * HOURLY_RATE + (decHours - 40) * HOURLY_RATE * 1.5)
Else
decGross = CDec(decHours * HOURLY_RATE)
End If
decFedTax = CDec(FED_TAX * (decGross - decDependents * DEPENDENTS))
decStateTax = CDec(STATE_TAX * decGross)
decNetPay = CDec(decGross - decFedTax - decStateTax)
txtCalculate.Text = CStr(decNetPay)