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...
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...
Submit a processed dataset and Python or SAS script that has been used along with a...
Submit a processed dataset and Python or SAS script that has been used along with a short description of the steps you have been following.
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,...
make a python script that has the following typed: school = “cochise college” place = “online”...
make a python script that has the following typed: school = “cochise college” place = “online” Then do the following with the given parameters.Set the script to have a function that takes two parameters, school and place, have your function return the first 5 characters of each parameter value, utilizing a slice. Change the script to have a function that takes two parameters, school and place, have your function return the first character of each parameter, utilizing an index value....
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....
#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
write a python script to calculate 401k with compounding interest
write a python script to calculate 401k with compounding interest
Question 3 Using R for calculations In a competitive company, the income levels of its employees...
Question 3 Using R for calculations In a competitive company, the income levels of its employees are not standardised and are awarded on a case-by-case basis after negotiations between individual employees and the company directors. An industry body wants an analysis of employee income with respect to their relative rank in the company. A random sample of 184 individuals in the company were recruited and their relative Rank and Income values were anonymously recorded. The data is available below. The...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT