1. Ask the user the number of hours worked 2. Capture the value of the hours variable from keyboard input 3. Ask the user their hourly pay rate 4. Capture the value of the pay_rate variable from keyboard input 5. Calculate the total earned by: a. 40 hours and under are payed at hourly rate b. Any hours over 40 are payed at 1.5x hourly rate 6. The total pay should be out put as currency 7. You final output should look like this: Your total pay is: SX,xxx.x To test your solution use the following information: Hours: 42 Pay Rate: $10/Hr Total pay should be S430.00

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter5: Making Decisions
Section: Chapter Questions
Problem 6RQ
icon
Related questions
Question
Need simple python code
Learning to use if - else statements:
Calculate wage with overtime
1. Ask the user the number of hours worked
2. Capture the value of the hours variable from keyboard imput
3. Ask the user their hourly pay rate
4. Capture the value of the pay_rate variable from keyboard imput
5. Calculate the total earned by
a. 40 hours and under are payed at hourly rate
b. Any hours over 40 are payed at 1.5x hourly rate
6. The total pay should be out put as currency
7. You final output should look like this:
Your total pavist SXxxxx
To test your solution use the following information:
Hours 42
Pay Rate: S10H
Total pay should be S430.00
Transcribed Image Text:Learning to use if - else statements: Calculate wage with overtime 1. Ask the user the number of hours worked 2. Capture the value of the hours variable from keyboard imput 3. Ask the user their hourly pay rate 4. Capture the value of the pay_rate variable from keyboard imput 5. Calculate the total earned by a. 40 hours and under are payed at hourly rate b. Any hours over 40 are payed at 1.5x hourly rate 6. The total pay should be out put as currency 7. You final output should look like this: Your total pavist SXxxxx To test your solution use the following information: Hours 42 Pay Rate: S10H Total pay should be S430.00
Expert Solution
Introduction

The main objective of the python program is to prompt the user to enter the number of hours. Read the value in the hours variable. Then, prompt to enter the pay rate as input from the keyboard. Read the value of the pay rate in the pay_rate variable.

Then calculate the total pay based on the number of hours with the following formula and then print the total payment value.

Case-i: If hours is less than or equal to 40 

Total pay=Hours × Pay rate

Case-iI: If hours are above 40 

Total pay=40×Hours +Hours-40× Pay rate×1.5

Step 2

The main.py python program source code

#main.py
def main():
    #Prompt user to enter number of hours as input
    hours=int(input("Enter number of hours : "))
    #Read pay rate from keyboard
    pay_rate=float(input("Enter pay rate,$"))
    #Check the condition , hours <=40
    if hours<=40:
        #calculate the total pay
        totalpay=hours*pay_rate
    else:
        #calculate the total pay over 40 hours
        totalpay=40*pay_rate+(hours-40)*pay_rate*1.5
    #print the total pay
    print("Your total pay is :${:,.2f} ".format(totalpay))

#call main function to start the program
main()

 

The screenshot of the source code with indentation 

Computer Science homework question answer, step 2, image 1

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Top down approach design
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage