Ask your own question, for FREE!
Computer Science 17 Online
OpenStudy (immanuelv):

can you guys take a look at this python problem

OpenStudy (immanuelv):

OpenStudy (anonymous):

what do you want

OpenStudy (e.mccormick):

What part are you having trouble with?

OpenStudy (immanuelv):

i finished my code .... can you guys tell me in any way i can improve my code :)

OpenStudy (immanuelv):

class Employee: def __init__(self): self.__hourWage = 7.25 self.__regHours = 0.0 self.__overHours = 0.0 def set_data(self, name, wage, hour): self.__name = str(name) workHours = str(hour) workHours = hour.split(sep=",") self.__hourWage = abs(float(wage)) for weeks in range(len(workHours)): workHours[weeks] = abs(float(workHours[weeks])) if workHours[weeks] > (40): self.__regHours += (40) self.__overHours += (workHours[weeks] - 40) else: self.__regHours += workHours[weeks] self.__regPay = ((self.__regHours) * (self.__hourWage)) self.__overPay = ((self.__overHours) * (self.__hourWage * 1.5 )) def get_data(self): return self.__name, self.__hourWage, self.__regHours, self.__overHours def get_regPay(self): return self.__regPay def get_overPay(self): return self.__overPay def allInfo(self): __totalHours = self.__regHours + self.__overHours __grossPay = self.__regPay + self.__overPay if __grossPay < 10000: __taxRate = .36 elif __grossPay < 6000: __taxRate = .31 elif __grossPay < 3500: __taxRate = .28 elif __grossPay < 2000: __taxRate = .15 else: __taxRate = .10 __totalTax = __grossPay * __taxRate __netPay = __grossPay - __totalTax print("Name :", self.__name,sep="") print("Regular Hours :", self.__regHours,sep="") print("Overtime Hours :", self.__overHours,sep="") print("Total Hours :", __totalHours,sep="") print("Pay Rate :", format(self.__hourWage, ",.2f"),sep="") print("Regular Pay :", format(self.__regPay, ",.2f"),sep="") print("Overtime Amount :", format(self.__overPay, ",.2f"),sep="") print("Monthly Gross Pay :", format(__grossPay, ",.2f"),sep="") print("Taxes :", format(__totalTax, ",.2f"),sep="") print("Monthly Net Pay :", format(__netPay,",.2f"),sep="") def main(): rerun = input("Employee Payroll- Press ENTER to continue") while rerun != "no": worker = Employee() name = input("Name (First Last) :") hourlyRate = input("Hourly Rate :") print("Enter your work hours for the weeks(ex: 44,40,30,55)") hours = input("Hours Worked :") worker.set_data(name, hourlyRate, hours) name, amount, regHours, overHours = worker.get_data() print("\nName :", name,sep="") print("Pay Rate :", amount,sep="") print("Regular Hours :", regHours,sep="") print("Overtime Hours :", overHours,sep="") regPay = worker.get_regPay() print("\n\nRegular Pay :",format(regPay, ",.2f",),sep="") overPay = worker.get_overPay() print("\nOvertime amount :",format(overPay, ",.2f"),sep="") worker.allInfo() print("\nDo you want to run the program again?") rerun = input("\t\t<yes/no>\t") print("Logging out...") main()

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!