Question

Exercise 1 A program was created that outputs the following unto the console: Hello! What is...

Exercise 1

A program was created that outputs the following unto the console:

Hello! What is your name:
Hello, Jane Doe! Using this program, we can help you determine you pay for the week!
Please enter the hours you worked this week: 20
Next, please enter your rate of pay: 10
Calculating… you will make $ 200 by the end of the week!

Here is the code for that program (you should have written a close variant of this last week

user_name = input("Hello! What is your name?\n")

#Write the same greeting above with the user’s name

print("Hello, " + user_name + "! Using this program, we can help you determine you pay for the week!")

#Ask the user for the rate of pay following the same format from the output above

hours_worked = float(input("Please enter the hours you worked this week:\n"))

rate_of_pay = float(input("Next, please enter your rate of pay:\n"))

#Create a variable that multiplies the hours_worked and the rate_of_pay

pay_for_week = hours_worked * rate_of_pay

#Write a print statement that will output the last line of the output provided

print("Calculating… you will make $" + str(pay_for_week) + " by the end of the week!")

Let's modify this program to comply with overtime rules. Let's give the employee 1.5 times the hourly rate for hours worked above 40 hours.

Here are some test cases:

  • If the number of hours worked is 45, and the rate of pay is 10, you should get 475.0 (10/hr for 40 hrs, and 15/hr for 5 hrs).
  • If the number of hours worked is 35, and the rate of pay is 10, you should get 350.0 (10/hr for 35 hrs).
  • If the number of hours worked is 63, and the rate of pay is 10, you should get 745.0 (10/hr for 40 hrs, and 15/hr for 23)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Python 3 code

============================================================================================

user_name = input("Hello! What is your name?\n")

#Write the same greeting above with the user’s name

print("Hello, " + user_name + "! Using this program, we can help you determine you pay for the week!")

#Ask the user for the rate of pay following the same format from the output above

hours_worked = float(input("Please enter the hours you worked this week:\n"))

rate_of_pay = float(input("Next, please enter your rate of pay:\n"))

#Create a variable that multiplies the hours_worked and the rate_of_pay

#overtime
if(hours_worked>40):
pay_for_week = 40 * rate_of_pay+(hours_worked-40)*rate_of_pay*1.5
else:
pay_for_week = hours_worked * rate_of_pay

#Write a print statement that will output the last line of the output provided

print("Calculating… you will make $" + str(pay_for_week) + " by the end of the week!")

============================================================================================

Output

Add a comment
Know the answer?
Add Answer to:
Exercise 1 A program was created that outputs the following unto the console: Hello! What is...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Hello I am confused about this C++ program. I need to create a payroll C++ program...

    Hello I am confused about this C++ program. I need to create a payroll C++ program following these steps. Source file structure Your program will consist of three source files: main.cpp the main program Payroll.hppclass declaration for the Payroll class. Make sure you have an include guard. Payroll.cpp Payroll's member functions Class definition Create a Payroll class definition. The class has private members which originate from user input: number of hours worked hourly rate float float - and private members...

  • Program Description: Write the pseudocode for a program that will calculate and display an employee’s gross...

    Program Description: Write the pseudocode for a program that will calculate and display an employee’s gross pay. Input the number of hours an employee worked for each of the 5 days of the week. Add them all up to get his hours worked for the week. Weekly Pay is calculated by adding an employee’s normal pay plus any overtime pay. Normal hours are paid at $10/hr. Any over time is paid at $15/hr. Any hours over 40 are considered overtime....

  • Requesting help with the following C Program: DESIGN and IMPLEMENT a menu driven program that uses...

    Requesting help with the following C Program: DESIGN and IMPLEMENT a menu driven program that uses the following menu and can perform all menu items: Enter a payroll record for one person Display all paycheck stubs Display total gross payroll from all pay records. Quit program The program will reuse the DATE struct from the previous assignment.  You should also copy in the functions relating to a DATE. The program will create a PAYRECORD struct with the following fields: typedef struct...

  • I am having a hard time with my program to assignment 4.12. Here are the instructions:...

    I am having a hard time with my program to assignment 4.12. Here are the instructions: The Payroll Department keeps a list of employee information for each pay period in a text file. The format of each line of the file is the following: <last name> <hours worked> <hourly wage> Write a program that inputs a filename from the user and prints to the terminal a report of the wages paid to the employees for the given period. The report...

  • It's my python assignment. Thank you You wrote a program to prompt the user for hours...

    It's my python assignment. Thank you You wrote a program to prompt the user for hours and rate per hour to compute gross pay. Also your pay computation to give the employee 1.5 times the hourly rate for hours worked above 40 hours. Enter Hours: 45 Enter Rate: 10 Pay: 475.0 (475 = 40 * 10 + 5 * 15) Rewrite your pay program using try and except so that your program handles non-numeric input gracefully. Enter Hours: 20 Enter...

  • C++ Program The Ward Bus Manufacturing Company has recently hired you to help them convert their...

    C++ Program The Ward Bus Manufacturing Company has recently hired you to help them convert their manual payroll system to a computer-based system. Write a program to produce a 1-week payroll report for only one employee to serve as a prototype (model) for the administration to review. Input for the system will be the employee’s 4-digit ID number, the employee’s name, hours worked that week, and the employee’s hourly pay rate. Output should consist of the employee’s ID number, the...

  • Data Programming l: PYTHON 1. Write a program that computes your gross pay. Your code should...

    Data Programming l: PYTHON 1. Write a program that computes your gross pay. Your code should get two numbers: hours and rate per hour. You should give the employee 1.75 times the hourly rate for hours worked above 40 hours. Output: Your gross pay is $487.5 2. Rewrite the previous program using try and except so that your program handles non-numeric inputs gracefully by printing a message and exiting the program. The following shows two executions of the program with...

  • Logic Exercise 40 Points This exercise tests your ability to understand logic in the form of...

    Logic Exercise 40 Points This exercise tests your ability to understand logic in the form of IF Statements. You will be given the rules and the data that will follow the logic. At the end of the explanation, a series of questions will be asked. Place your answers in the area provided. Program explanation - You are provided with pseudocode that calculates the total amount of money to pay an employee after working for 1 week. The amount of money...

  • A) One of the problems that have been discussed in the class is to write a simple C++ program to ...

    C++ programming question will upvote A) One of the problems that have been discussed in the class is to write a simple C++ program to determine the area and circumference of a circle of a given radius. In this lab you will be rewriting the program again but this time you will be writing some functions to take care of the user input and math. Specifically, your main function should look like the following int main //the radius of the...

  • THIS IS WHAT I HAVE I NEED TO FIX IT SO: hours_worked should not be inputed...

    THIS IS WHAT I HAVE I NEED TO FIX IT SO: hours_worked should not be inputed separately. Get the hours as 40 40 40 40 or 40, 40, 40, 40 whichever separator suits you. How do I do this? How would you change what I have in to it getting into that kind of input. Thank you! class Employee: again = 'y' def __init__(self): self.__rate = 7.25 self.__totalhour = 0 self.__regularpay = 0 self.__overtimepay = 0 self.__totalpay = 0 self.__tax...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT