Question

In: Computer Science

Create a program wages.py that assumes people are paid double time for hours over 60. They...

Create a program wages.py that assumes people are paid double time for hours over 60. They get paid for at most 20 hours overtime at 1.5 times the normal rate.

For example, a person working 65 hours with a regular wage of $10 per hour would work at $10 per hour for 40 hours, at 1.5 * $10 for 20 hours of overtime, and 2 * $10 for 5 hours of double time, for a total of

10*40 + 1.5*10*20 + 2*10*5 = $800.

The number of hours should be generated randomly between 35 and 75.

If the number of working hours is less than 40, display message “The salary cannot be generated” with sound of system bell as a warning.

Solutions

Expert Solution

The Python code to randomly generate a number of hours worked betwee 35,75 and to calculate wages according to given condition is:

# Importing random library to use random() function
# Importing winsound to generate a beep sound using winsound.beep()
import random
import winsound

# randomly generating a number in range (35,75)
# using random.randrange(35,75)
hours = random.randrange(35,75)
# Fixing basic wages as 20
wage=20

# Checking if number of hours worked is less than 40
if(hours<40):
    print("Number of hours worked: {}".format(hours))
    print("The Salary can't be generated")
    # Setting frequency, duration to generate warning sound
    frequency = 2500 
    duration = 1000  
    # Generating beep sound using winsound.beep(frequency,duration) function
    winsound.Beep(frequency, duration)
else:
    print("Number of hours worked: {}".format(hours))
    print("Pay per hour 20\nOvertime 30/hour for less than 60 hours\nOvertime 40/hour for greater than 60 hours")

# If number of hours worked greater than 40
# Cheking all conditions and calculating total wage
if(hours>40):
    if hours<=60:
        pay= (40*wage)+ (hours-40)*(wage*1.5)
    if hours>60:
        pay = (40*wage)+ (60-40)*(wage*1.5) + (hours-60)*(wage*2)
    print("Your pay: {}".format(pay))

For hous less than 40 "Salaray can't be generated" message is displayed with a beeep sound from system. The sound is produced using winsound.beep(frequency, duration) function found in winsound library.

If the hours greater than 40 then I have calulated wage for first 40 hours $20/hour and 1.5 times 20 i,e $30/hour for 40 to 60 hours and for greater than 60 hours double the wage i.e $40/hour and printed the result.

If you need to change the basic wage from $20 to some other value, you can just change the wage variable in code.

I have tested the code many times and validated the output by checking calculation by hand. The code is working fine. I am sharing few output screenshots for your reference.

Hope this answer helps you.

Thank you :)


Related Solutions

The length of time, in hours, it takes an "over 40" group of people to play...
The length of time, in hours, it takes an "over 40" group of people to play one soccer match is normally distributed with a mean of 2.2 hours and a standard deviation of 0.55 hours. A sample of size n = 80 is drawn randomly from the population. Find the probability that the sample mean is between 2.1 hours and 2.4 hours.
The length of time, in hours, it takes an "over 40" group of people to play...
The length of time, in hours, it takes an "over 40" group of people to play one soccer match is normally distributed with a mean of 4 hours and a standard deviation of 0.5 hours. A sample of size n = 50 is drawn randomly from the population. Find the probability that the sample mean is between 3.5 hours and 4.1 hours.
Exercise 2: Write a program in Java to manipulate a Double Linked List: 1. Create Double...
Exercise 2: Write a program in Java to manipulate a Double Linked List: 1. Create Double Linked List 2. Display the list 3. Count the number of nodes 4. Insert a new node at the beginning of a Double Linked List. 5. Insert a new node at the end of a DoubleLinked List 6. Insert a new node after the value 5 of Double Linked List 7. Delete the node with value 6. 8. Search an existing element in a...
Create a program “Fib.java” and a method called “double[] getFib)” that creates an array with a...
Create a program “Fib.java” and a method called “double[] getFib)” that creates an array with a length of 15 that contains the first 15 numbers in the Fibonacci sequence and returns it. Set the first element to 0 and the second element to 1, then use a for loop to fill out the rest of the array.
give your theory or idea on why time is 24 hours, why are their 60 minute's...
give your theory or idea on why time is 24 hours, why are their 60 minute's in an hour and 60 seconds in a minute. Why did early civilizations pick these particular numbers for time. Give your response with a paragraph explaining your theory, idea and or argument.
Write a program that request a time interval in seconds and display it in hours, minutes,...
Write a program that request a time interval in seconds and display it in hours, minutes, second format. (java)
Problems create a C++ program that will do the followings - define 3 double variables x,...
Problems create a C++ program that will do the followings - define 3 double variables x, y, z - calculate the value of y as the following formula: y = 2*x*x+4*x+5 and print x and y; - assign a new value to x: x=5.6 - calculate the value of z as the following formula z = (y*y)/4 + (x*x)/5 - print x, y,x
8) Create the following program using Java. Circle calculation using methods Create scanner declare double variable...
8) Create the following program using Java. Circle calculation using methods Create scanner declare double variable radius = -999 declare character choice create do while loop inside of do loop write: System.out.println(); System.out.println("*** CIRCLE CALCULATIONS ***"); System.out.println(); System.out.println("1. Enter the radius of the circle"); System.out.println("2. Display the area of the circle"); System.out.println("3. Display the circumference of the circle"); System.out.println("4. Quit"); System.out.println(); System.out.println("Enter a number from 1 - 4"); System.out.println(); Declare choice character and relate to scanner declare switch (choice) case...
Write a program where you- 1. Create a class to implement "Double Linked List" of integers....
Write a program where you- 1. Create a class to implement "Double Linked List" of integers. (10) 2. Create the list and print the list in forward and reverse directions. (10)
Create a C # program that calculates what a worker must be paid if each day...
Create a C # program that calculates what a worker must be paid if each day I work different hours during the week. The price per hour is 80.0.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT