Question

In: Computer Science

Python 3 Script: A company has classified its employees as follows.

Python 3 Script: A company has classified its employees as follows.

Managers Hourly workers

Commission workers Pieceworkers

- who receive a fixed weekly salary
- who receive a fixed hourly wage for up to the first 40 hours they work and

“time-and-a-half”, i.e. 1.5 times their hourly wage, for overtime hours worked), - who receive $250 plus 5.7% of their gross weekly sales)
- who receive a fixed amount of money per item for each of the items they

Produce. Each pieceworker in this company works on only one type of item. Write a Python program to compute the weekly pay for each employee. You do not know the number of employees in advance.

Each type of employee has its own pay method. A Manager has a weekly salary and is entered while processing. Hourly worker’s salary is calculated by multiplying the rate-per-hour and the number-of- hours-worked. Commission worker’s salary is based on the gross weekly sales and uses the formula shown above. Pieceworker’s salary is calculated by multiplying the rate-per-piece and the number-of- pieces completed. Prompt the user to enter the appropriate facts your program needs to calculate each employee’s pay based on that employee’s category.

Solutions

Expert Solution

Screenshot of the code:

Sample Output:

Code to copy:

#Define the function getManagerPay() to display the

#weekly sales entered for the managers.

def getManagerPay(weekly_salary_for_manager):

    print("\nThe weekly pay for the managers "

    + "is ${:.2f}\n".format

    (weekly_salary_for_manager))

#Define the function getHourlyWorkerWeeklyPay() to

#calculate and display the weekly pay for the hourly

#worker.

def getHourlyWorkerWeeklyPay(hourly_wage, hours_worked):

    weeklyPayForHourlyWorker = 0.0

    #If the total hours worked is less than or equal to

    #40.

    if(hours_worked <= 40):

        #Calculate the weeklyPayForHourlyWorker by

        #muliplying hourly wages with total hours

        #worked.

        weeklyPayForHourlyWorker = hourly_wage * \

        hours_worked

   

    #Otherwise,

    elif(hours_worked > 40):

        #Multiply the remaining working hours after the

        #initial 40 hours with the 1.5 times the hourly

        #wages.

        weeklyPayForHourlyWorker = (hours_worked - 40) * \

        1.5 * hourly_wage

    #Display the final weekly pay for hourly workers.

    print("\nThe weekly pay for hourly workers "

    + "is ${:.2f}\n".format(weeklyPayForHourlyWorker))

#Define the function getWeeklyPayForCommissionWorker()

#to calculate and display the weekly pay for the

#commission worker.

def getWeeklyPayForCommissionWorker(gross_weekly_sales):

    weeklyPayForCommissionWorker = 0.0

    #Add 250 to the 5.7% of the gross weekly sales.

    weeklyPayForCommissionWorker = 250 + 0.057 * \

    (gross_weekly_sales)

    #Display the final weekly pay for commission workers.

    print("\nThe weekly pay for the commission workers "

    + "is ${:.2f}\n".format(weeklyPayForCommissionWorker))

#Define the function getWeeklyPayForPieceWorker() to

#calculate and display the weekly pay for the

#pieceworker.

def getWeeklyPayForPieceWorker(rate_per_item,

num_items_produced):

    weeklyPayForPieceWorker = 0.0

    #Multiply the price per item produced with the

    #number of items produced.

    weeklyPayForPieceWorker = rate_per_item * \

    num_items_produced

   

    #Display the final weekly pay for pieceworkers.

    print("\nThe weekly pay for the pieceworkers "

    + "is ${:.2f}\n".format(weeklyPayForPieceWorker))

print("****** Employee Payment System ******")

#Start a while loop.

while True:

    #Display the menu of choices.

    print("1. Managers")

    print("2. Hourly Workers")

    print("3. Commission Workers")

    print("4. Piece Workers")

    #Prompt the user to enter a valid choice or -1 to

    #quit.

    userChoice = int(input("\nEnter your choice out "

    + "of the options given in the menu or enter -1 "

    + "to quit: "))

   

    #If user choose -1, then break the loop.

    if(userChoice == -1):

        print("Bye!!!")

        break

   

    #If user's choice is 1, then prompt the user to

    #enter the weekly salary for managers.

    elif(userChoice == 1):

        weekly_salary_for_manager = 0.0

        weekly_salary_for_manager = float(input("Enter "

        + "the weekly sales: "))

        #Call the function getManagerPay() and pass the

        #value weekly_salary_for_manager as argument.

        getManagerPay(weekly_salary_for_manager)

    #If user's choice is 2, then prompt the user to

    #enter the hourly wages and number of hours an

    #employee worked.

    elif(userChoice == 2):

        hourlyWages = float(input("Enter the hourly "

        + "wage for hourly workers: "))

        totalHoursWorked = int(input("Enter the number "

        + "of hours worked: "))

        #Call the function getHourlyWorkerWeeklyPay() by

        #passing the hourlyWages and totalHoursWorked to

        #the function as arguments.

        getHourlyWorkerWeeklyPay(hourlyWages,

        totalHoursWorked)

  

    #If user's choice is 3, then prompt the user to

    #enter the gross weekly sales for the commission

    #employee.

    elif(userChoice == 3):

        grossWeeklySales = float(input("Enter the gross "

        + "weekly sales for the commission workers: "))

        #Call the function

        #getWeeklyPayForCommissionWorker() and pass the

        #value grossWeeklySales as argument.

        getWeeklyPayForCommissionWorker

        (grossWeeklySales)

   

    #If user's choice is 4, then prompt the user to

    #enter the price for each item produced and number

    #of items produced.

    elif(userChoice == 4):

        payRatePerItem = float(input("Enter the pay "

        + "rate per item produced: "))

        numberOfPieces = int(input("Enter the number "

        + "of items produced: "))

        #Call the function getWeeklyPayForPieceWorker()

        #by passing the payRatePerItem and

        #numberOfPieces as function arguments.

        getWeeklyPayForPieceWorker(payRatePerItem,

        numberOfPieces)

   

    #Otherwise, display an appropriate message.

    else:

        print("\nInvalid Choice!\n")


Related Solutions

In Python Create customer information system as follows: Python 3 Create customer information system as follows:...
In Python Create customer information system as follows: Python 3 Create customer information system as follows: Ask the user to enter name, phonenumber, email for each customer. Build a dictionary of dictionaries to hold 10 customers with each customer having a unique customer id. (random number generated) Take the keys of the above mentioned dictionary which are customer ids and make a list. Ask the use to enter a customer id and do a binary search to find if the...
How do I write a script for this in python in REPL or atom, NOT python...
How do I write a script for this in python in REPL or atom, NOT python shell Consider the following simple “community” in Python . . . triangle = [ ["top", [0, 1]], ["bottom-left", [0, 0]], ["bottom-right", [2, 0]], ] This is the calling of function. >>> nearestneighbor([0, 0.6], triangle, myeuclidean) 'top' The new point is (0, 0.6) and the distance function is Euclidean. Now let’s confirm this result . . . >>> myeuclidean([0, 0.6], [0, 1]) 0.4 >>> myeuclidean([0,...
Granger Company has a profit sharing plan for its 10 employees. Three of the employees are...
Granger Company has a profit sharing plan for its 10 employees. Three of the employees are highly compensated and receive annual bonuses. The other seven employees are hourly employees who receive overtime pay periodically. Which of the following provisions would be considered discriminatory in the company's plan allocation formula? Please give detailed explanation. A. The plan provides a higher rate of allocation for employees who have more years of service. B. The plan defines compensation to include bonuses but not...
#python. Explain code script of each part using comments for the reader. The code script must...
#python. Explain code script of each part using comments for the reader. The code script must work without any errors or bugs. Ball moves in a 2D coordinate system beginning from the original point (0,0). The ball can move upwards, downwards, left and right using x and y coordinates. Code must ask the user for the destination (x2, y2) coordinate point by using the input x2 and y2 and the known current location, code can use the euclidean distance formula...
write a python script for rock scissors paper game
write a python script for rock scissors paper game
Create a Python script in IDLE or Kali Python3 CLI to create the following Python Program:...
Create a Python script in IDLE or Kali Python3 CLI to create the following Python Program: Your program will create a username of your choice using a Kali Linux command "useradd -m mark", then set the password for that user using the Kali Linux Command "echo "mark:10101111" | chpasswd". Then you create a dictionary file using the Kali Linux command "crunch 8 8 01 > mylist.txt" Your python script should crack the password for that user and display on the...
Write the following Python script: Imagine you live in a world without modules in Python! No...
Write the following Python script: Imagine you live in a world without modules in Python! No numpy! No scipy! Write a Python script that defines a function called mat_mult() that takes two lists of lists as parameters and, when possible, returns a list of lists representing the matrix product of the two inputs. Your function should make sure the lists are of the appropriate size first - if not, your program should print “Invalid sizes” and return None. Note: it...
Write the following Python script: Imagine you live in a world without modules in Python! No...
Write the following Python script: Imagine you live in a world without modules in Python! No numpy! No scipy! Write a Python script that defines a function called mat_mult() that takes two lists of lists as parameters and, when possible, returns a list of lists representing the matrix product of the two inputs. Your function should make sure the lists are of the appropriate size first - if not, your program should print “Invalid sizes” and return None. Note: it...
Turner Inc. provides a defined benefit pension plan to its employees. The company has 150 employees....
Turner Inc. provides a defined benefit pension plan to its employees. The company has 150 employees. The remaining amortization period at December 31, 2016, for prior service cost is 5 years. The average remaining service life of employees is 11 years at January 1, 2017, and 10 years at December 31, 2017. The AOCI—net actuarial (gain) loss was zero at December 31, 2016. Turner smooths recognition of its gains and losses when computing its market-related value to compute expected return....
Create and Compile a Python Script without using Numpy that Generate an nxn matrix using Python...
Create and Compile a Python Script without using Numpy that Generate an nxn matrix using Python Script (ie n=user input) Ask (user input ) and (randomly generated) row and column location Assign Q to (known row and column location ) and 0 to all others location Please show compile script working as well
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT