Write pseudocode and implement a Python program for the following problem. 1. Re
ID: 3860864 • Letter: W
Question
Write pseudocode and implement a Python program for the following problem. 1. Read in: the name of an employee, followed by the number of hours worked by the employee (an integer that is guaranteed to be greater than 0), the pay rate of the employee (a float that is guaranteed to be greater than 0), and the tax rate (as a percentage) for the employee (again, a float that is guaranteed to be greater than 0) 2. Compute the total pay for the employee by multiplying the pay rate and the number of hours worked. Store the total pay in an appropriately-named variable. 3. Compute the tax withholding for the employee by multiplying the total pay by the tax rate divided by 100. Store the withholding in an appropriately-named variable. 4. Compute the net pay for the employee by subtracting the witholding from the total pay. Store the net pay in an variable. 5. Print the name of the employee, the number of hours worked, the pay rate, the total pay, the withholding, and the net pay (Sample Execution). Create a file with the extension.py in IDLE. In the first few lines of this file, type # Author # This must be followed by the pseudocode for the program as Python comments. Do not write pseudocode in the following ways: Using Python constructs Going at a very high level with no details on how something could be achieved. Some students write the pseudocode after developing the Python code. This is a poor approach to problem solving, Although this may fetch you points, you will not gain valuable problem solving experience. The rest of the Python file will have the Python code you create by converting the above pseudocode.Explanation / Answer
Pseudocode is as follows:
while (read the file):
Read(employee data, file)
name := emplpoyee name
number of hours := num of hours employee worked
pay rate := pay rate of the employee
tax rate = tax rate of the employee
Calculate
total pay := number of hours * pay rate
withholding := (total pay * tax rate 0/100
net pay = total pay - withholding
print name
print number of hours
print pay rate
print total pay
print withholding
print net pay
close(file)
The code is as follows:
#!usr/python/bin
infile = open('input.txt', 'r') ''' Assuming file name is input.txt"
for line in infile:
name = line.split(' ')[0]
num_hrs = line.split(' ')[1]
pay_rate = line.split(' ')[2]
tax_rate = line.split(' ')[3]
total_pay = int(num_hrs) * int(pay_rate)
withholding = (total_pay * float(tax_rate))/100
net_pay = total_pay - withholding
print("Name:",name)
print("No of hours:",num_hrs)
print("Pay Rate:", pay_rate)
print("Tax Rate:", tax_rate)
print("Total Pay:", total_pay)
print("Withholding:", withholding)
print("Net Pay:",net_pay);
print("")
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.