Question

In: Computer Science

class employee: name = str('')    hourlyWage=0 hoursWorked=0 def getPayment(self): payment=self.hourlyWage*self.hoursWorked return payment    class payrollApp(employee):...

class employee:
name = str('')
  
hourlyWage=0
hoursWorked=0
def getPayment(self):
payment=self.hourlyWage*self.hoursWorked
return payment
  

class payrollApp(employee):
  
def printStatement(self):
print('The Employee Name is ' + self.name)
print('The Employee Hourly wage is ' + str(self.hourlyWage))
print('No of hours worked ' + str(self.hoursWorked))
print('The Employee payment is ' + str(employee.getPayment(self)))

emp = []
x=0
a=True
totalPayout=0
while a:
  
emp.append(payrollApp())
emp[x].name=input("Enter Employee Name: ")
emp[x].hourlyWage=int(input("Enter hourly wage: "))
emp[x].hoursWorked=int(input("Enter No of hours worked: "))
totalPayout= totalPayout + (emp[x].hourlyWage * emp[x].hoursWorked)
print("\n")
x=x+1
b=input("Do you want to enter new employee yes or no ")
print('\n')
if b=='no':
a=False
  

for obj in emp:
obj.printStatement()
print('\n')
  
print("The total payout for all employees combined is " + str(totalPayout))

how can i add overtime into this and calculate the number of employees entered?

Solutions

Expert Solution

Python code included overtime and number of employees entered.

class employee:
    name = str('')
    hourlyWage = 0
    hoursWorked = 0
    # added overtime hours and wages
    overtimeHourlyWage = 0
    overtimeHoursWorked = 0

    # added payment of overtime
    def getPayment(self):
        payment = (self.hourlyWage * self.hoursWorked) + (self.overtimeHourlyWage * self.overtimeHoursWorked)
        return payment


class payrollApp(employee):
    def printStatement(self):
        print('The Employee Name is ' + self.name)
        print('The Employee Hourly wage is ' + str(self.hourlyWage))
        print('No of hours worked ' + str(self.hoursWorked))
        print('The Employee overtime Hourly wage is ' + str(self.overtimeHourlyWage))
        print('No of overtime hours worked ' + str(self.overtimeHoursWorked))
        print('The Employee payment is ' + str(employee.getPayment(self)))


if __name__ == '__main__':
    emp = []
    x = 0
    a = True
    totalPayout = 0
    while a:
        emp.append(payrollApp())
        emp[x].name = input("Enter Employee Name: ")
        emp[x].hourlyWage = int(input("Enter hourly wage: "))
        emp[x].hoursWorked = int(input("Enter No of hours worked: "))

        # Taking overtime input
        emp[x].overtimeHourlyWage = int(input("Enter overtime hourly wage: "))
        emp[x].overtimeHoursWorked = int(input("Enter No of overtime hours worked: "))
        totalPayout = totalPayout + emp[x].getPayment()
        print("\n")
        x = x + 1
        b = input("Do you want to enter new employee yes or no ")
        print('\n')
        if b == 'no':
            a = False

    for obj in emp:
        obj.printStatement()
    print('\n')

    # print total number of employees
    print("Total number of employees: " + str(x))
    print("The total payout for all employees combined is " + str(totalPayout))

Image for indentation : 

Output :

Enter Employee Name: abc
Enter hourly wage: 100
Enter No of hours worked: 6
Enter overtime hourly wage: 120
Enter No of overtime hours worked: 2


Do you want to enter new employee yes or no yes


Enter Employee Name: xyz
Enter hourly wage: 120
Enter No of hours worked: 8
Enter overtime hourly wage: 150
Enter No of overtime hours worked: 1


Do you want to enter new employee yes or no no


The Employee Name is abc
The Employee Hourly wage is 100
No of hours worked 6
The Employee overtime Hourly wage is 120
No of overtime hours worked 2
The Employee payment is 840
The Employee Name is xyz
The Employee Hourly wage is 120
No of hours worked 8
The Employee overtime Hourly wage is 150
No of overtime hours worked 1
The Employee payment is 1110


Total number of employees: 2
The total payout for all employees combined is 1950

Hope you like it

Any Query? Comment Down!

I have written for you, Please up vote the answer as it encourage us to serve you Best !


Related Solutions

python class Node(): def __init__(self, value): pass class PostScript(): def __init__(self): pass    def push(self, value):...
python class Node(): def __init__(self, value): pass class PostScript(): def __init__(self): pass    def push(self, value): pass    def pop(self): return None    def peek(self): pass    def is_empty(self): pass def stack(self): pass    def exch(self): pass    def index(self): pass    def clear(self): pass    def dup(self): pass    def equal(self): pass    def depth(self): pass    stack = PostScript() def decode(command_list): for object in command_list: if object == '=': stack.equal() elif object == 'count': stack.depth() elif object ==...
Inheritance - Method Calls Consider the following class definitions. class C1(): def f(self): return 2*self.g() def...
Inheritance - Method Calls Consider the following class definitions. class C1(): def f(self): return 2*self.g() def g(self): return 2 class C2(C1): def f(self): return 3*self.g() class C3(C1): def g(self): return 5 class C4(C3): def f(self): return 7*self.g() obj1 = C1() obj2 = C2() obj3 = C3() obj4 = C4() For this problem you are to consider which methods are called when the f method is called. Because the classes form part of an inheritance hierarchy, working out what happens will...
Inheritance - Method Calls Consider the following class definitions. class C1(): def f(self): return 2*self.g() def...
Inheritance - Method Calls Consider the following class definitions. class C1(): def f(self): return 2*self.g() def g(self): return 2 class C2(C1): def f(self): return 3*self.g() class C3(C1): def g(self): return 5 class C4(C3): def f(self): return 7*self.g() obj1 = C1() obj2 = C2() obj3 = C3() obj4 = C4() For this problem you are to consider which methods are called when the f method is called. Because the classes form part of an inheritance hierarchy, working out what happens will...
For python... class car:    def __init__(self)          self.tire          self.gas    def truck(self,color)        &nb
For python... class car:    def __init__(self)          self.tire          self.gas    def truck(self,color)               style = color                return    def plane(self,oil)              liquid = self.oil + self.truck(color) For the plane method, I am getting an error that the class does not define __add__ inside init so I cannot use the + operator. How do I go about this.             
from PIL import Image def stringToBits(string):     return str(bin(int.from_bytes(string.encode(), 'big')))[2:] def bitsToString(bits):     if bits[0:2] != '0b':         bits.
from PIL import Image def stringToBits(string):     return str(bin(int.from_bytes(string.encode(), 'big')))[2:] def bitsToString(bits):     if bits[0:2] != '0b':         bits = '0b' + bits     value = int(bits, 2)     return value.to_bytes((value.bit_length() + 7) // 8, 'big').decode() def writeMessageToRedChannel(file, message):     image = Image.open(file)     width, height = image.size     messageBits = stringToBits(message)     messageBitCounter = 0     y = 0     while y < height:         x = 0         while x < width:             r, g, b, a = image.getpixel((x, y))             print("writeMessageToRedChannel: Reading pixel %d, %d - Original values (%d, %d, %d, %d)"...
public static char mostFrequent(String str) {        if(str.length()==0) {            return '0';   ...
public static char mostFrequent(String str) {        if(str.length()==0) {            return '0';        }        String temp="";        for (int i = 0; i < str.length(); i++) {                 if(!temp.contains(String.valueOf(str.charAt(i)))) {                     temp += String.valueOf(str.charAt(i));                 }             }        char[] tempArray=stringToArray(temp);        int[] countArr=new int[tempArray.length];        int max=0;        for(int i=0;i<tempArray.length;i++) {            int cnt=numOccurences(tempArray[i],str);            countArr[i]=cnt;...
Can you tell me what is wrong with this code ? def update_char_view(phrase: str, current_view: str,...
Can you tell me what is wrong with this code ? def update_char_view(phrase: str, current_view: str, index: int, guess: str)->str: if guess in phrase: current_view = current_view.replace(current_view[index], guess) else: current_view = current_view    return current_view update_char_view("animal", "a^imal" , 1, "n") 'animal' update_char_view("animal", "a^m^l", 3, "a") 'aamal'
class Board: def __init__(self): self.pieces = [[None for i in range(8)] for j in range(8)] def...
class Board: def __init__(self): self.pieces = [[None for i in range(8)] for j in range(8)] def __str__(self): s = "" for j in range(7, -1, -1): #for each row for i in range(8): # for each column if self.pieces[j][i] is None: # if self.pieces[j][i] is None s += "." # populate the row with '.' val for each column else: s += self.pieces [j][i].get_symbol() s += "\n" #after each row add a new line return s # return after iterating...
def warmer_year(temps_then: List[int], temps_now: List[int]) -> List[str]: """Return a list of strings representing whether this year's...
def warmer_year(temps_then: List[int], temps_now: List[int]) -> List[str]: """Return a list of strings representing whether this year's temperatures from temps_now are warmer than past temperatures in temps_then. The resulting list should contain "Warmer" at the indexes where this year's temperature is warmer, and "Not Warmer" at the indexes where the past year was warmer, or there is a tie. Precondition: len(temps_then) == len(temps_now) >>> warmer_year([10], [11]) ['Warmer'] >>> warmer_year([26, 27, 27, 28], [25, 28, 27, 30]) ['Not Warmer', 'Warmer', 'Not Warmer',...
Recall the is_hour(str) and is_minute(str) functions return True if the str contains valid hour and minute respectively
Recall the is_hour(str) and is_minute(str) functions return True if the str contains valid hour and minute respectively. That is, is_hour("03:65") would return True and is_minute("03:65") would return False.For each of the following expression, indicate whether short-circuit evaluation would occur. That is, the function call on the LHS of the logic operator would not actually be evaluated.ExpressionShort-circuit evaluationExpressionShort-circuit evaluationis_hour("03:65") and is_minute("03:65")--YesNois_hour("03:65") or is_minute("03:65"--YesNois_minute("03:65") and is_hour("03:65")--YesNois_minute("03:65") and is_hour("03:65")--YesNo
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT