5 Replies - 21800 Views - Last Post: 05 May 2009 - 01:23 PM Rate Topic: -----

#1 poncia23   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 30-April 09

Payroll program using python

Post icon  Posted 04 May 2009 - 11:36 AM

Hi, i have a question, i need to do a project for my programming class in school. Its a payroll program asking the user to input full name,rate,hrs worked,and other deductions, i'm having a tough time starting it. Can someone help me please.
Is This A Good Question/Topic? 0
  • +

Replies To: Payroll program using python

#2 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6259
  • View blog
  • Posts: 24,028
  • Joined: 23-August 08

Re: Payroll program using python

Posted 04 May 2009 - 11:59 AM

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: :code:

Thanks.
Was This Post Helpful? 0
  • +
  • -

#3 zombie_chan51   User is offline

  • D.I.C Regular

Reputation: 7
  • View blog
  • Posts: 327
  • Joined: 16-March 08

Re: Payroll program using python

Posted 05 May 2009 - 06:28 AM

Well what do you need help with?
Was This Post Helpful? 0
  • +
  • -

#4 poncia23   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 30-April 09

Re: Payroll program using python

Posted 05 May 2009 - 12:55 PM

View Postdrjoe51, on 5 May, 2009 - 05:28 AM, said:

Well what do you need help with?


This is what i have so far:
hRate="no"
while hRate=="no":
    hRate=input ('Pleae enter your hourly rate')
    if hRate < 6.5 or hRate > 15:
        print "Please enter a valid rate between 6.50 and 15.00"


numHrs=="no"
while numHrs=="no":
    numHrs=input ('Please enter the number of hours worked this week')
    if numHrs < 20 or numHrs > 60:
        print "Please enter a valid number of hours between 20-60"


grossPay= (hRate * numHrs)
if numHrs >40:
    grossPay=(40 * hRate) + ((numHrs>40) * (hRate * 1.5))
    

if taxCode==0:
    fedTax = grossPay * .10
    stateTax = grossPay * .05
elif taxCode==1:
    fedTax = grossPay * .08
    stateTax = grossPay * .04
elif taxCode==2:
    fedTax = grossPay * .05
    stateTax = grossPay * .03
elif taxCode==3:
    fedTax = grossPay * .03
    stateTax = grossPay * .02


This is the message i get:
Traceback (most recent call last):
  File "C:/Documents and Settings/Adrian/Desktop/Final Lab.py", line 8, in <module>
    numHrs=="no"
NameError: name 'numHrs' is not defined
>>>

Was This Post Helpful? 0
  • +
  • -

#5 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6259
  • View blog
  • Posts: 24,028
  • Joined: 23-August 08

Re: Payroll program using python

Posted 05 May 2009 - 01:05 PM

Please use code tags!!!

Don't you have an extra = in here?
numHrs=="no"

Was This Post Helpful? 0
  • +
  • -

#6 poncia23   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 30-April 09

Re: Payroll program using python

Posted 05 May 2009 - 01:23 PM

View PostJackOfAllTrades, on 5 May, 2009 - 12:05 PM, said:

Please use code tags!!!

Don't you have an extra = in here?
numHrs=="no"


I know this is stupid mistake that im making this is the code:

hRate="no"
while hRate=="no":
hRate=input ('Pleae enter your hourly rate')
if hRate < 6.5 or hRate > 15:
print "Please enter a valid rate between 6.50 and 15.00"


numHrs="no"
while numHrs=="no":
numHrs=input ('Please enter the number of hours worked this week')
if numHrs < 20 or numHrs > 60:
print "Please enter a valid number of hours between 20-60"


grossPay= (hRate * numHrs)
if numHrs >40:
grossPay=(40 * hRate) + ((numHrs>40) * (hRate * 1.5))


taxCode="no"
while taxCode=="no":
taxCode=input ('Please select a tax deduction code that best fits you')
if taxCode==0:
fedTax = grossPay * .10
stateTax = grossPay * .05
elif taxCode==1:
fedTax = grossPay * .08
stateTax = grossPay * .04
elif taxCode==2:
fedTax = grossPay * .05
stateTax = grossPay * .03
elif taxCode==3:
fedTax = grossPay * .03
stateTax = grossPay * .02


ficaTax = grossPay * .06
medDeduction="no"
while medDeduction=="no":
medDeduction=input('Please select your medical and dental code')
if medDeduction==0:
medDuct = grossPay - 0
elif medDeduction==1:
medDuct = grossPay - 25
elif medDeduction==2:
medDuct = grossPay - 50
elif medDeduction==3:
medDuct = grossPay -75
elif medDeduction > 3:
medDuct = grossPay - 100


netPay = (grossPay) - fedTax,stateTax,ficaTax,medDuct

The output:
Pleae enter your hourly rate12
Please enter the number of hours worked this week40
Please select a tax deduction code that best fits you0
Please select your medical and dental code1

im not getting what im suppose to get.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1