Note that there are some explanatory texts on larger screens.

plurals
  1. POSupport on Payroll Code Error?
    primarykey
    data
    text
    <p>Im getting a few errors from this code, can anyone explain what seems to be the issue? Thanks! This program is supposed to calculate the payroll for a declared (counter) amount of employees. Note: This is Python 3.3</p> <p>Also: please feel free to make any improvements you like! I am looking to learn!</p> <pre><code>def computeGrossPay(hours, rate): if hours &gt; 40: grossPay = (40 * rate) + ((hours - 40) * 1.5 * hours) else: grossPay = hours * rate return grossPay def computeTaxAmount(status, grossPay): if status == 1: if grossPay &lt;= 42: taxAmount = 0 elif grossPay &gt; 42 and grossPay &lt;= 214: taxAmount = (grossPay - 15) * .1 elif grossPay &gt; 214 and grossPay &lt;= 739: taxAmount = 17.2 + ((grossPay - 214) * .15) elif grossPay &gt; 739 and grossPay &lt;= 1732: taxAmount = 95.95 + ((grossPay - 739) * .28) elif grossPay &gt; 1732 and grossPay &lt;= 2566: taxAmount = 344.2 + ((grossPay - 1732) * .28) elif grossPay &gt; 3566 and grossPay &lt;= 7703: taxAmount = 857.72 + ((grossPay - 3566) * .33) elif grossPay &gt; 7703 and grossPay &lt;= 7735: taxAmount = 2222.93 + ((grossPay -7703) * .35) elif grossPay &gt; 7735: taxAmount = 2234.13 + ((grossPay - 7735) * .396) elif status == 2: if grossPay &lt;= 160: taxAmount = 0 elif grossPay &gt; 160 and grossPay &lt;= 503: taxAmount = (grossPay - 160) * .1 elif grossPay &gt; 503 and grossPay &lt;= 1554: taxAmount = 34.3 + ((grossPay - 503) * .15) elif grossPay &gt; 1554 and grossPay &lt;= 2975: taxAmount = 191.95 + ((grossPay - 1554) * .28) elif grossPay &gt; 2975 and grossPay &lt;= 4449: taxAmount = 547.2 + ((grossPay - 2975) * .28) elif grossPay &gt; 4449 and grossPay &lt;= 7820: taxAmount = 959.92 + ((grossPay - 4449) * .33) elif grossPay &gt; 7820 and grossPay &lt;= 8813: taxAmount = 2072.35 + ((grossPay -7820) * .35) elif grossPay &gt; 8813: taxAmount = 2419.9 + ((grossPay - 8813) * .396) return taxAmount def computeNetPay(grossPay, taxAmount): netPay = grossPay - taxAmount return netPay def main(): totalGrossPay = 0 print("Welcome to the Payroll Program") counter = eval(input("How many employees will be entered? \n")) for i in range(counter): name = input("What are the first and last names of the employee? \n") id = input("What are the last four numbers of his/her Social Security Number? \n") hours = eval(input("How many hours did they work? \n")) rate = eval(input("What was the rate? \n")) while (True): status = eval(input("Are they single(1) or married(2)? \n")) if status != 1 or 2: break grossPay = computeGrossPay(hours, rate) taxAmount = computeTaxAmount(status, grossPay) netPay = computeNetPay(grossPay, taxAmount) totalGrossPay = totalGrossPay + grossPay averageGrossPay = totalGrossPay / counter print("The ID is ", id) print("The name is ", name, ".") print("This employee worked ", hours, " hours.") print("The hourly rate was ", rate) print("The gross pay was $", grossPay) print("The tax amount withheld for the week is $", taxAmount) print("The net pay is $", netPay) print("The total gross pay was $", totalGrossPay) print("The average gross pay was $", averageGrossPay) main() </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload