In: Computer Science
in python language
The Payroll Department keeps a list of employee information for each pay period . The format of each line of the file is the following:
<lastname> < hours worked> < Income>
Write a program that inputs from the user and prints to the terminal a report of the wages paid to the employees for the given period. The report should be in tabular format with the appropriate header. Each line should contain an employee’s name, the hours worked, and the wages paid for that period.
Output example:
Lastname |
Hours worked |
Income |
Lambert |
120 |
$1000 |
q2
Write a program to read and calculate the tax due for each income.
The amount of tax is calculated using the following table. For example, if an income is $1500, the formula to compute the tax is: 7.5 + (1500-750)*0.02 , that results in the tax amount to be $22.5.
Income |
Amount of tax |
Not over $750 |
1% of income |
$750 to $2,250 |
$7.5 plus 2% of amount over $750 |
$2,250 to $3,750 |
$37.50 plus 3% of amount over $2,250 |
$3,750 to $5,250 |
$82.50 plus 4% of amount over $3,750 |
$5,250 to $7,000 |
$142.50 plus 5% of amount over $5,250 |
Over $7000 |
$230.00 plus 6% of amount over $7,000 |
Output example:
Lastname |
Hours worked |
Income |
Tax |
Lambert |
120 |
$1000 |
$12.5 |
PYTHON CODE(Q1)
firstName = []#List of first name of employee
lastName = []#List of last name of employee
hoursWorked = []#List of hours worked
income = []#List of income of employee
ch = ''
while ch!='n' and ch!='N':#Get details of employees
firstName.append(input("Enter Employee's first name:"))
lastName.append(input("Enter Employee's last name:"))
hoursWorked.append(int(input("Enter hours worked:")))
income.append(int(input("Enter income amount:")))
ch = input("Want to continue?(y/n):")
print("LastnameHours workedIncome")
for ind in range(len(firstName)):#Display employees details
print("%s%s$%s"%(lastName[ind].ljust(8,' '), str(hoursWorked[ind]).ljust(12,' '), str(income[ind]).ljust(5,' ')))
PYTHON CODE SCREENSHOT
OUTPUT SCREENSHOT
PYTHON CODE(Q2)
def calculateTax(income):#function calculate the tax for given income
if income <= 750:
return 750*0.01
elif income > 750 and income <= 2250:
return 7.5 + ((income - 750) * 0.02)
elif income > 2250 and income <= 3750:
return 37.50 + ((income - 2250) * 0.03)
elif income > 3750 and income <= 5250:
return 82.50 + ((income - 3750) * 0.04)
elif income > 5250 and income <= 7000:
return 142.50 + ((income - 5250) * 0.05)
elif income > 7000:
return 230.00 + ((income - 7000) * 0.06)
firstName = []#List of first name of employee
lastName = []#List of last name of employee
hoursWorked = []#List of hours worked
income = []#List of income of employee
ch = ''
while ch!='n' and ch!='N':#Get details of employees
firstName.append(input("Enter Employee's first name:"))
lastName.append(input("Enter Employee's last name:"))
hoursWorked.append(int(input("Enter hours worked:")))
income.append(int(input("Enter income amount:")))
ch = input("Want to continue?(y/n):")
print("LastnameHours workedIncomeTax")
for ind in range(len(firstName)):#Display employees details
tax = calculateTax(income[ind])
print("%s%s$%s$%.1f"%(lastName[ind].ljust(8,' '), str(hoursWorked[ind]).ljust(12,' '), str(income[ind]).ljust(5,' '), tax))
PYTHON CODE SCREENSHOT
OUTPUT SCREENSHOT