In: Computer Science
Please write in Python 3.7.4 or Higher.
The Payroll Department keeps a list of employee information for each pay period in a text file. The format of each line of the file is the following: <last name> <hours worked> <hourly wage>
Write a program that inputs a filename from the user and prints to the terminal a report of the wages paid to the employees for the given period.
An example of the program input and output is shown below:
Enter the file name: data.txt Name Hours Total Pay Lambert 34 357.00 Osborne 22 137.50 Giacometti 5 503.50
Given below is the code for the question. Ensure to indent as
shown in image.
Please do rate the answer if it helped. Thank you
filename = input('Enter input filename: ')
try:
f = open(filename, 'r')
except:
print('Error opening file ' , filename)
exit()
print('{:<12s} {:>10s} {:>10s}'.format('Name', 'Hours',
'Total Pay'))
for line in f.readlines():
lname, hours, wage = line.split()
hours = int(hours)
wage = float(wage)
total = hours * wage
print('{:<12s} {:>10d}
{:>10.2f}'.format(lname, hours, total))
f.close()