p108ex9: Pay

You are to calculate weekly pay of T employees (1 ≤ T ≤ 1000) based on four factors : rate of pay in dollars, hours worked, tax category, and donations.

Any hours worked over 40 is considered "overtime" and is paid double.

The five tax categories are,

Tax Category Tax Deduction
A 0% Tax
B 10% tax
C 20% tax
D 29% tax
E 35% tax


Input starts with T, followed by the information for T employees on four separate lines. Each employee's information will be seperated with one newline.

Line 1 : a real number denoting rate of hourly pay in dollars (≤ 1000).
Line 2 : an integer denoting hours worked. (< 30000).
Line 3 : a character denoting the tax category of how much tax the government collects.
Line 4 : a "y" or "n" denoting whether they want to donate 10 dollars. Donations are calculated last.


Output each employee's pay in dollars, rounded to two decimal places.

Sample Input



Sample Output


All Submissions
Best Solutions

Point Value: 4
Time Limit: 2.00s
Memory Limit: 16M
Added: Oct 26, 2008

Languages Allowed:

Comments (Search)

I've checked my code, and it works with the first input (as found with ss3happy1). What should I do to fix it?

print(round(pay, 2))
print("%.2f" %(round(pay, 2)))
, because as in the sample, you are to output 2 decimal places, were if the answer was 4.0, you only outputted 4.0, not 4.00.

For some reason, I keep getting 0/10 even though the code works fine in my ide. Help?

@Waffles, I want to say that you have been way too active in the comments section, please give some time and try to solve the problem yourself, if you can't, give it some time, then try again, considering this is quite a trivial question, I feel like your comment isn't at the right place. The comment section is used for clarification purposes mainly

peter, you cant hard code this, lol (but please, on a serious sidenote, please to not hard code, it doesn't help you in any way

I ran my code on my computer and it works perfectly, yet when I submit I get 0 marks?

I doubt it works on your machine...

NameError: name 'b' is not defined


Is this the correct input values for the 1st guy's pay?
If so, I was wondering what should be the correct output, my program prints 15116.54

I was just wondering about this, because the second line (indicating hours) is 18467, but the question states that it hours must be less than 216. This is the source of my confusion.

I've updated the problem statement to correctly reflect the range of values. Sorry about this.

15116.54 is indeed the correct output for that input.

Thanks for the reply Jargon!

I was just wondering if you could take a look at my submission and see why I get 0/10. I would figure I would at least get 1/10 for getting the first output right then.

The only possible marks from this problem are 0/10, if any case is wrong, and 10/10, if all cases are right.

I don't understand, I rounded my code to 2 decimal places, yet it's saying my output is wrong, and is at like 10 decimal places ? It's rounded in my code

Those numbers with the large amount of decimal places are from your debug (I assume) output: the problem never asks you to print out their overtime pay before taxes.

why is it not accepting my answer? I get the answers right on my computer but on the website it keeps saying i have wrong answer. I matched all the inputs case to case, it still doesn't accept....

Most of the lines outputted by your program are wrong. Lines 1, 6, 11, 16, ... 96 are correct, the rest are wrong. Make of that what you will.

Can I have clarification on input 2? I've worked it through by hand, and I'm not getting the same answer.
Base pay is $1/hr * 41 hours = $41. Right?
Adding double pay is + $1/hr * (41 - 41 = 1) hours = +$1 = $42.
Subtracting tax is -10% = 42 - 4.2 = 37.8...?
Then the donation of $10 makes it $27.80.

So what's wrong?
Thanks in advance for the help.

The solution submitted by the admin account gives the same answer, so the problem statement has been corrected.