In: Computer Science
my program should work for ANY NUMBER OF WORKERS..after all worker gross and net pay have been calculated, you should display the total number of workers, the total gross pay, and the total net pay.
Employee ID
Employee Name
The number of hours worked
The Employees hourly wage…
i used while loop
EmpName= input(str("PLease enter Employee name: or press -1 to exit: "))
while EmpName != "-1":
EmpID= input("Enter Employee ID: ")
how do i write this in a list form? if i enter 5 employee names, the program has to calcalate how many employees and total pays?
pls help
thanks
Java code pasted below.
#Initialize totalgrosspay and totalnetpay to 0
totalgrosspay=totalnetpay=0
#Initialize an empty list
emplist=[]
while True:
#Reading all the details for the employee
empid=input("Enter Employee ID:")
empname=input("Enter Employee Name:")
hours=int(input("Enter the number of hours worked:"))
wages=int(input("Enter hourly wages:"))
deductions=int(input("Enter the amount for deductions:"))
#calculating grosspay and netpay
grosspay=hours*wages
netpay=grosspay-deductions
#Add the details as atuple to the list called emplist
emplist.append((empid,empname,hours,wages,deductions,grosspay,netpay))
#calculating total grosspay and total net pay for all
employees
totalgrosspay=totalgrosspay+grosspay
totalnetpay=totalnetpay+netpay
t=input("Enter -1 to exit or press enter to continue:")
if t=="-1": break
print()
print("Total number of employees:",len(emplist))
print("Total Gross Pay of all Employees:",totalgrosspay)
print("Total Net Pay of all Employees:",totalnetpay)
print()
print("EmpID\tName\tHours worked\tWages\tDeductions\tGross pay\tNet
pay")
for i in range(0,len(emplist)):
print(emplist[i][0],"\t",emplist[i][1],"\t",emplist[i][2],"\t\t",emplist[i][3],"\t\t",emplist[i][4],"\t",emplist[i][5],"\t\t",emplist[i][6])
Java code in IDLE pasted for better understanding of the
indent.
Output Screen