![MZ2017](/avatars/13391.jpg)
MZ2017
02.03.2020 •
Computers and Technology
Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay should be the normal rate for hours up to 40 and time-and-a-half for the hourly rate for all hours worked above 40 hours. Put the logic to do the computation of time-and-a-half in a function called computepay() and use the function to do the computation. The function should return a value. Use 45 hours and a rate of 10.50 per hour to test the program (the pay should be 498.75). You should use input to read a string and float() to convert the string to a number. Do not worry about error checking the user input unless you want to - you can assume the user types numbers properly. Do not name your variable sum or use the sum() function.
def computepay(h,r):
hrs = input("Enter Hours:")
h = float(hrs)
rate = input("Enter Rate:")
r = float(rate)
pay = (h * r)
if h <= 40 :
return(pay)
else :
ovrhrs = (h-40)
regular = (r*40)
othrs = ovrhrs * (r *1.5)
ovrpay = (regular + othrs)
return(ovrpay)
print(computepay(45,10.5))
Solved
Show answers
More tips
- C Computers and Internet Thin Client: What It Is and Why You Need It?...
- F Food and Cooking The Most Delicious and Simple Fish in Batter Recipe...
- D Dating, Love, Relationships How Long Can Love Last?...
- A Auto and Moto Mastering One-Movement Parking: All You Need to Know...
- C Computers and Internet How to Properly Order Clothing from International Online Stores...
- H Health and Medicine Headache: A Comprehensive Guide to Treatment...
- F Family and Home How to Choose the Best Diapers for Your Baby?...
- A Auto and Moto Discovering the Leader: What is the Most Expensive Car in the World?...
- F Food and Cooking How to Quickly Put your Child to Sleep?...
- C Computers and Internet How to Create a Website for Free and Easy?...
Answers on questions: Computers and Technology
- C Computers and Technology HELP ME PLEASE I NEED THIS RN....
- M Mathematics The original price of a bottle of dish soap is $2. How much will Sasha PAY if she buys it during the sale when it is 50% off?...
- M Mathematics Question 2(Multiple Choice Worth 5 points) When solving negative one over five (x − 25) = 7, what is the correct sequence of operations? Multiply each side by negative one over five...
- M Mathematics Solve for the variable x in this equation z=6 π xy...
- B Biology In fruit flies (Drosophila melanogaster), there are multiple genes that influence eye color. One of these genes, located on the X chromosome, affects whether a fly has white or red...
Ответ:
B
Explanation:
You listed this as Computers and Technology where we post coding questions, or hardware related things, but ok.
If there is 7/8 jugs as the starting amount, and they have a 1/2 jug, dividing 0.875 by 0.5 gives the answer of 1.75 or 1 3/4.