What's new

Python, help po

DarkResurrection

Eternal Poster
Established
Joined
May 28, 2016
Posts
813
Solutions
1
Reaction
140
Points
295
Good day po ! Help po sana about sa code ko, ang gusto ko po sana sa bandang "State withholding" under "Deductions"sa code ko ay i print lang yung two decimal places po pero hindi po siya mag-ra-round off. Example is 8.775, ang gusto ko lang po na lalabas is 8.77 at hindi 8.78. Ito po code ko,


Python:
name = input("Enter employee's name: ")
num_hours_worked = input("Enter number of hours worked in a week: ")
hour_pay_rate = input("Enter hourly pay rate: ")
fed_tax = input("Enter federal tax withholding rate: ")
state_tax = input("Enter state tax withholding rate: ")
gross_pay = float(num_hours_worked) * float(hour_pay_rate)
compute_state_withholding = float(state_tax) * float(gross_pay)
total_deduction = float(fed_tax) * float(gross_pay) + float(compute_state_withholding)
net_pay = float(gross_pay) - float(total_deduction)
print()
print('Employee name: ' + name)
print('Hours worked: ' + str(float(num_hours_worked)))
print('Pay rate: $' + str(float(hour_pay_rate)))
print('Gross Pay: $' + str(float(gross_pay)))
print('Deductions:')
print(' Federal Withholding: (' + str(float(fed_tax) * 100) + '%): $' + str(float(fed_tax) * float(gross_pay)))
print(' State Withholding: (' + str(float(state_tax) * 100) + '%): $' + str(format(compute_state_withholding, ".2f")))
print(' Total Deduction: $' + str(format(total_deduction, ".2f")))
print('Net Pay: $' + str(format(net_pay, ".2f")))

attach ko na din po yung sample output na binigay po

Capture.PNG


Thank you in advance po! ^_^
 

Attachments

Similar threads

Back
Top