Question

THIS IS WHAT I HAVE I NEED TO FIX IT SO:

hours_worked should not be inputed separately.

Get the hours as 40 40 40 40 or 40, 40, 40, 40 whichever separator suits you﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿.

How do I do this?

How would you change what I have in to it getting into that kind of input.

Thank you!

class Employee:
again = 'y'
def __init__(self):
self.__rate = 7.25
self.__totalhour = 0
self.__regularpay = 0
self.__overtimepay = 0
self.__totalpay = 0
self.__tax = 0
self.__netpay = 0

def set_name(self):
self.__name = input("Enter your name (First Last): ")

def set_rate(self):
self.__rate = float(input("Enter your hourly rate: "))

def set_hour(self):
h1 = 0
h2 = 0
oh = 0
for a in range(1, 5):
hours = int(input("Enter hours worked for week :"))
if hours > 40:
oh += hours - 40
h1 += 40
else:
h2 += hours
self.__Rhour = h1 + h2
self.__Ohour = oh

def set_total_hour(self):
self.__totalhour = self.__Rhour + self.__Ohour

def set_regular_pay(self):
self.__regularpay = self.__Rhour * self.__rate

def set_overtime_pay(self):
self.__overtimepay = self.__Ohour*(self.__rate * 1.5)

def set_total_pay(self):
self.__totalpay = self.__regularpay + self.__overtimepay

def set_tax(self):
if self.__totalpay > 10000:
self.__tax = self.__totalpay * 0.36
elif self.__totalpay > 6000:
self.__tax = self.__totalpay * 0.31
elif self.__totalpay > 3500:
self.__tax = self.__totalpay * 0.28
elif self.__totalpay > 2000:
self.__tax = self.__totalpay * 0.15
else:
self.__tax = self.__totalpay * 0.1

def set_net_pay(self):
self.__netpay = self.__totalpay - self.__tax

def get_name(self):
return self.__name

def get_rate(self):
return self.__rate

def get_regular_hour(self):
return self.__Rhour

def get_overtime_hour(self):
return self.__Ohour

def get_total_hour(self):
return self.__totalhour

def get_regular_pay(self):
return self.__regularpay

def get_overtime_pay(self):
return self.__overtimepay

def get_total_pay(self):
return self.__totalpay

def get_tax(self):
return self.__tax

def get_net_pay(self):
return self.__netpay

def __str__(self):

return "Employee`s name: " + self.get_name() +\
"\nRegular hours worked: " + str(self.get_regular_hour())+\
"\nOvertime hours worked: " + str(self.get_overtime_hour()) +\
"\nTotal hours worked: " + str(self.get_total_hour())+\
"\nPay rate: \$" + str(format(self.get_rate(),',.2f')) +\
"\nRegular Pay: \$" + str(format(self.get_regular_pay(),',.2f')) +\
"\nMonthly overtime pay: \$" + str(format(self.get_overtime_pay(),',.2f')) +\
"\nMonthly gross pay: \$" + str(format(self.get_total_pay(),',.2f')) +\
"\nMonthly taxes: \$" + str(format(self.get_tax(),',.2f')) +\
"\nMonthly net pay: \$" + str(format(self.get_net_pay(),',.2f'))

again = "y"
while again == "y":
main()
print()
again = input("Do you want to run the program again < y - Yes / n - No>? ")
print()
print()

def main():

test = Employee()

test.set_name()
test.set_rate()
print()
test.set_hour()
test.set_total_hour()
test.set_regular_pay()
test.set_overtime_pay()
test.set_total_pay()
test.set_tax()
test.set_net_pay()

print()

print(test)

In case of any query do comment. Thanks

Code:

=================main.py========

``````class Employee:
again = 'y'
def __init__(self):
self.__rate = 7.25
self.__totalhour = 0
self.__regularpay = 0
self.__overtimepay = 0
self.__totalpay = 0
self.__tax = 0
self.__netpay = 0

def set_name(self):
self.__name = input("Enter your name (First Last): ")

def set_rate(self):
self.__rate = float(input("Enter your hourly rate: "))

def set_hour(self):
h1 = 0
h2 = 0
oh = 0
#get the list of hours separated by comma
hour1,hour2,hour3,hour4 = [int(hour) for hour in input("Enter hours worked for week :").split(",")]
hours = [hour1,hour2,hour3,hour4] #construct a list to iterate for common logic in for each else write separately for each hour
#iterate over hours entered by the user and calculate regular and overtime hours
for h in hours:
if h > 40:
oh += h - 40
h1 += 40
else:
h2 += h
self.__Rhour = h1 + h2
self.__Ohour = oh

def set_total_hour(self):
self.__totalhour = self.__Rhour + self.__Ohour

def set_regular_pay(self):
self.__regularpay = self.__Rhour * self.__rate

def set_overtime_pay(self):
self.__overtimepay = self.__Ohour*(self.__rate * 1.5)

def set_total_pay(self):
self.__totalpay = self.__regularpay + self.__overtimepay

def set_tax(self):
if self.__totalpay > 10000:
self.__tax = self.__totalpay * 0.36
elif self.__totalpay > 6000:
self.__tax = self.__totalpay * 0.31
elif self.__totalpay > 3500:
self.__tax = self.__totalpay * 0.28
elif self.__totalpay > 2000:
self.__tax = self.__totalpay * 0.15
else:
self.__tax = self.__totalpay * 0.1

def set_net_pay(self):
self.__netpay = self.__totalpay - self.__tax

def get_name(self):
return self.__name

def get_rate(self):
return self.__rate

def get_regular_hour(self):
return self.__Rhour

def get_overtime_hour(self):
return self.__Ohour

def get_total_hour(self):
return self.__totalhour

def get_regular_pay(self):
return self.__regularpay

def get_overtime_pay(self):
return self.__overtimepay

def get_total_pay(self):
return self.__totalpay

def get_tax(self):
return self.__tax

def get_net_pay(self):
return self.__netpay

def __str__(self):

return "Employee`s name: " + self.get_name() +\
"\nRegular hours worked: " + str(self.get_regular_hour())+\
"\nOvertime hours worked: " + str(self.get_overtime_hour()) +\
"\nTotal hours worked: " + str(self.get_total_hour())+\
"\nPay rate: \$" + str(format(self.get_rate(),',.2f')) +\
"\nRegular Pay: \$" + str(format(self.get_regular_pay(),',.2f')) +\
"\nMonthly overtime pay: \$" + str(format(self.get_overtime_pay(),',.2f')) +\
"\nMonthly gross pay: \$" + str(format(self.get_total_pay(),',.2f')) +\
"\nMonthly taxes: \$" + str(format(self.get_tax(),',.2f')) +\
"\nMonthly net pay: \$" + str(format(self.get_net_pay(),',.2f'))

again = "y"
while again == "y":
main()
print()
again = input("Do you want to run the program again < y - Yes / n - No>? ")
print()
print()

def main():
test = Employee()
test.set_name()
test.set_rate()
print()
test.set_hour()
test.set_total_hour()
test.set_regular_pay()
test.set_overtime_pay()
test.set_total_pay()
test.set_tax()
test.set_net_pay()

print()

print(test)

=======Code modification highlight=======

output:

#### Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
• ### Python 3 Question Please keep the code introductory friendly and include comments. Many thanks. Prompt: The...

Python 3 Question Please keep the code introductory friendly and include comments. Many thanks. Prompt: The owners of the Annan Supermarket would like to have a program that computes the weekly gross pay of their employees. The user will enter an employee’s first name, last name, the hourly rate of pay, and the number of hours worked for the week. In addition, Annan Supermarkets would like the program to compute the employee’s net pay and overtime pay. Overtime hours, any...

• ### If the employee is a supervisor calculate her paycheck as her yearly salary / 52 (weekly...

If the employee is a supervisor calculate her paycheck as her yearly salary / 52 (weekly pay) If the employee is not a supervisor and she worked 40 hours or less calculate her paycheck as her hourly wage * hours worked (regular pay) If the employee is not a supervisor and worked more than 40 hours calculate her paycheck as her (hourly wage * 40 ) + (1 ½ times here hourly wage * her hours worked over 40) (overtime...

• ### Design a program(Creating a RAPTOR flowchart) that will read a file of employee records containing employee...

Design a program(Creating a RAPTOR flowchart) that will read a file of employee records containing employee number, employee name, hourly pay rate, regular hours worked and overtime hours worked. The company pays its employees weekly, according to the following rules: regular pay = regular hours worked × hourly rate of pay overtime pay = overtime hours worked × hourly rate of pay × 1.5 total pay = regular pay + overtime pay Your program is to read the input data...

• ### Introduction to computer class, Java programming through eclipse: Ue the following criteria to create the code:...

Introduction to computer class, Java programming through eclipse: Ue the following criteria to create the code: SALARY Input first and last name - Output the names last, first in your output - Make the federal withholding rate a constant 20% (not an input value) No state tax Generate two new values: regular pay and overtime pay - 40 hours workedor less - Regular pay is pay rate * hours worked - Overtime pay is 0 Otherwise - Regular pay is...

• ### I have to write a program where the program prints a deck of cards. instead of having your regula...

I have to write a program where the program prints a deck of cards. instead of having your regular suits and numbers the program will use a value for a number, id will be either rock, paper, or scissors, and the coin will be heads or tails. print example: 2 of rock heads. If the user is enters 1 the program will print out 30 of the print example and arrange them by there values. if the user enters 2...

• ### Exercise 1 A program was created that outputs the following unto the console: Hello! What is...

Exercise 1 A program was created that outputs the following unto the console: Hello! What is your name: Hello, Jane Doe! Using this program, we can help you determine you pay for the week! Please enter the hours you worked this week: 20 Next, please enter your rate of pay: 10 Calculating… you will make \$ 200 by the end of the week! Here is the code for that program (you should have written a close variant of this last...

• ### Python 3 Question: All I need is for someone to edit the program with comments that...

Python 3 Question: All I need is for someone to edit the program with comments that explains what the program is doing (for the entire program) def main(): developerInfo() #i left this part out retail = Retail_Item() test = Cash_Register() test.data(retail.get_item_number(), retail.get_description(), retail.get_unit_in_inventory(), retail.get_price()) answer = 'n' while answer == 'n' or answer == 'N': test.Menu() print() print() Number = int(input("Enter the menu number of the item " "you would like to purchase: ")) if Number == 8: test.show_items() else:...

• ### I am currently facing a problem with my python program which i have pasted below where i have to design and implement python classes and record zoo database and takes user input as query. the error i...

I am currently facing a problem with my python program which i have pasted below where i have to design and implement python classes and record zoo database and takes user input as query. the error i am recieving says that in line 61 list index is out of range. kindly someone help me with it as soon as possible. Below is the program kindly check and correct it. Thanks! class Animal: def __init__(self, name, types, species, mass): self.name=name self.type=types...

• ### For my computer class I have to create a program that deals with making and searching...

For my computer class I have to create a program that deals with making and searching tweets. I am done with the program but keep getting the error below when I try the first option in the shell. Can someone please explain this error and show me how to fix it in my code below? Thanks! twitter.py - C:/Users/Owner/AppData/Local/Programs/Python/Python38/twitter.py (3.8.3) File Edit Format Run Options Window Help import pickle as pk from Tweet import Tweet import os def show menu():...

• ### I am currently facing a problem with my python program which i have pasted below where...

I am currently facing a problem with my python program which i have pasted below where i have to design and implement python classes and record zoo database and takes user input as query. the error i am recieving says that in line 61 list index is out of range. kindly someone help me with it as soon as possible. Below is the program kindly check and correct it. Thanks! class Animal: def __init__(self, name, types, species, mass): self.name=name self.type=types...