-1

So i had to convert my pseudocode to python but my output isnt coming out the way it should be.

i enter the 40 hours work and 20 pay rate but the gross pay isnt coming out (gross pay should be 800). can anyone tell me whats wrong?

BASE_HOURS = 40
OT_MULTIPLIER = 1.5

def main():
    hours_worked = int(input('Enter the number of hours worked: '))
    pay_rate = int(input('Enter the hourly pay rate: '))

    if hours_worked > BASE_HOURS:
        calc_pay_with_OT(hours_worked, pay_rate)
    else:
        calc_regular_pay(hours_worked, pay_rate)

def calc_pay_with_OT(hours, pay_rate):
    overtime_hours = hours_worked - BASE_HOURS

    overtime_pay = overtime_hours * pay_rate + OT_MULTIPLIER

    gross_pay = BASE_HOURS * pay_rate + overtime_pay

    print('The gross pay is $ '), gross_pay

def calc_regular_pay(hours, pay_rate):
    gross_pay = hours * pay_rate

    print('The gross pay is $ '), gross_pay 

main() 
holdenweb
  • 33,305
  • 7
  • 57
  • 77
  • Enter the number of hours worked: 40 Enter the hourly pay rate: 20 The gross pay is $ >>> this is my output but there should be 800 after the $ – polskiebmw Sep 19 '16 at 21:24
  • Runs fine and gives me 800 our for 40 and 20 in. What's wrong? – holdenweb Sep 19 '16 at 21:24
  • I get the correct answer of $800 when I run your program. – The Dude Sep 19 '16 at 21:24
  • @holdenweb when i run it i dont get the gross pay. its just blank after the $. it should display "$ 800" instead of just "$" – polskiebmw Sep 19 '16 at 21:26
  • Hope you don't mind, I edited the language to remove the "run snippet" button (which didn't work). How are you trying to run this code? – holdenweb Sep 19 '16 at 21:26
  • Only thing I can think of is that is an issue with the print statement itself. Try instead, `print('The gross pay is $ '+str(gross_pay))` – The Dude Sep 19 '16 at 21:27
  • @holdenweb im running it with python and even tried CMD nothing worked. But i did what The Dude told me and it worked! – polskiebmw Sep 19 '16 at 21:29
  • @TheDude what does that +str stuff do? it worked! im new to coding – polskiebmw Sep 19 '16 at 21:29

1 Answers1

0

The print statement should instead be print('The gross pay is $'+str(gross_pay)) The str() function converts the integer gross_pay into a string so that it can be concatenated in the print function.

The Dude
  • 1,036
  • 1
  • 12
  • 22