Question

In: Computer Science

Goals: Concepts related to conditional statements in Python. This is a Python program. You DON’T need...

Goals: Concepts related to conditional statements in Python. This is a Python program. You DON’T need loops for this.

Below is the programming task.

An employee is paid at a rate of $17.25 per hour for up to 40 regular hours worked in a week. If the employee works more than 40 hours, it is considered overtime. Any hours over 40 hours but less than or equal to 60 are paid at the overtime rate ($12.34 per hour). Any hours over 60 hours but less than equal to 80 hours are paid at the overtime rate ($14.34 per hour). Any hours over 80 hours are paid at the overtime rate ($16.00 per hour).

From the worker’s gross pay, 14% is withheld for federal income tax, 5% is withheld for state income tax. $80 is withheld to cover the insurance of the worker and 2 dependents. If the worker has more than 2 dependents, then an additional $25 is withheld per dependent for insurance. Write a python program that will read in the name of the employee, number of hours worked in a week and the number of dependents as input. The program should then output the worker’s name, number of dependents, gross pay, each withholding amount, and the net take-home pay for the week.

Note that the ONLY INPUTS the user provides are

- The employee’s name.

- The number of hours worked in the week.

- The number of dependents.

Below are four Sample I/O

Net Paycheck Calculator

Employee's Name: John Smith

Number of Hours Worked in a Week: 43

Number of Employee's Dependents: 3

---------------------------------------------------------------------

Employee's name :John Smith

Number of Dependents :3

Hours worked :43

Overtime hours :3

Gross Income :$727.02

State Tax Withheld @ 5% :$36.35

Federal Tax Withheld @ 14% :$101.78

Worker and 2 Dependents' Insurance :$80.00

Additional Dependents' Insurance :$25.00

---------------------------------------------------------------------

Net Take Home Pay :$483.89

Net Paycheck Calculator

Employee's Name: John Smith

Number of Hours Worked in a Week: 63

Number of Employee's Dependents: 0

---------------------------------------------------------------------

Employee's name :John Smith

Number of Dependents :0

Hours worked :63

Overtime hours :23

Gross Income :$979.82

State Tax Withheld @ 5% :$48.99

Federal Tax Withheld @ 14% :$137.17

Worker and 2 Dependents' Insurance :$80.00

Additional Dependents' Insurance :$0.00

---------------------------------------------------------------------

Net Take Home Pay :$713.65

Net Paycheck Calculator

Employee's Name: John Smith

Number of Hours Worked in a Week: 35

Number of Employee's Dependents: 2

---------------------------------------------------------------------

Employee's name :John Smith

Number of Dependents :2

Hours worked :35

Overtime hours :0

Gross Income :$603.75

State Tax Withheld @ 5% :$30.19

Federal Tax Withheld @ 14% :$84.53

Worker and 2 Dependents' Insurance :$80.00

Additional Dependents' Insurance :$0.00

---------------------------------------------------------------------

Net Take Home Pay :$409.04

Net Paycheck Calculator

Employee's Name: John Smith

Number of Hours Worked in a Week: 82

Number of Employee's Dependents: 4

---------------------------------------------------------------------

Employee's name :John Smith

Number of Dependents :4

Hours worked :82

Overtime hours :42

Gross Income :$1255.60

State Tax Withheld @ 5% :$62.78

Federal Tax Withheld @ 14% :$175.78

Worker and 2 Dependents' Insurance :$80.00

Additional Dependents' Insurance :$50.00

---------------------------------------------------------------------

Net Take Home Pay :$887.04

Solutions

Expert Solution

import random
import sys
import os


# Python Program to find Area of a Rectangle using Functions

#taking input
print(" Net Paycheck Calculator ")
name = input("Employee's Name: ")
H_worked = int(input('Number of Hours Worked in a Week:'))
Depen = int(input('Number of Employee\'s Dependents:'))

extra = max(0,Depen-2)
O_hours = H_worked - 40
hours = H_worked;
type1 = 0
type2 = 0
type3 = 0
reg_hour = min(H_worked,40)
hours = hours - min(H_worked,40)


#divided the over time in three types
#type1= 40 to 60
#type2 = 60 to 80
#type3 = 80 to above

if(hours>0):
type1 = min(hours,20)
hours = hours- 20
if(hours>0):
type2 = min(hours,20)
hours = hours- 20
if(hours>0):
type3 = hours

Gross = reg_hour*17.25 + type1*12.34 + type2*14.34 + type3*16 #calculated gross salary
f_tax = Gross * 0.14

s_tax = Gross * .05 #state tax
insurence_fixed = 80 #fixed insurence of 2 dependents
insurence_add = extra*25 #additional insurence of more than 2 dependents

net = Gross- (f_tax + insurence_fixed + insurence_add + s_tax) #calculated net pay

#printed all the things
print(" ---------------------------------------- " )
print(" Employee's name:%s" %name)
print(" Number of Dependents: %d" %Depen)
print(" Hours worked :%d" %H_worked)
print(" Overtime hours :%d" %O_hours)

print(" Gross Income :$%d" %Gross)
print(" State Tax Withheld @5%%:$%.2f" %s_tax)
print(" Federal Tax Withheld @14%%:$%.2f" %f_tax)
print(" Worker and 2 Dependents' Insurance: %.2f" %insurence_fixed)
print(" Additional Dependents' Insurance: %.2f" %insurence_add)

print(" ---------------------------------------- " )
print(" Net Take Home Pay:$ %.2f" %net)


Related Solutions

Design a Python example that includes the following Basic concepts: Loops Conditional statements two of the...
Design a Python example that includes the following Basic concepts: Loops Conditional statements two of the advanced concepts: Encryption / Decryption, Lists / Dictionaries Please leave a Description of the program
how are mission statements, program goals, program objectives, and a program philosophy related?
how are mission statements, program goals, program objectives, and a program philosophy related?
Goals Practice conditional statements Description Write a program to simulate a menu driven calculator that performs...
Goals Practice conditional statements Description Write a program to simulate a menu driven calculator that performs basic arithmetic operations (add, subtract, multiply and divide). The calculator accepts two numbers and an operator from user in a given format: For example: Input: 6.3 / 3 Output: 2.1 Create a Calculator class that has a method to choose the right mathematical operation based on the entered operator using switch case. It should then call a corresponding method to perform the operation. In...
ON PYTHON Exercise 4. Insert one or more conditional statements at the end of the source...
ON PYTHON Exercise 4. Insert one or more conditional statements at the end of the source code listed in exercise4.py that prints the messages ‘You entered a negative number’, ‘You entered a zero’, or ‘You entered a positive number’ based on the value entered by the user. value = int( input( 'Enter the value: ') ) # insert the additional statement(s) here Exercise 5. Insert one or more conditional statements at the end of the source code listed in exercise5.py...
PYTHON Program Problem Statement: Write a Python program that processes information related to a rectangle and...
PYTHON Program Problem Statement: Write a Python program that processes information related to a rectangle and prints/displays the computed values. The program will behave as in the following example. Note that in the two lines, Enter length and Enter width, the program does not display 10.0 or 8.0. They are values typed in by the user and read in by the program. The first two lines are text displayed by the program informing the user what the program does. This...
Write the program in Java. Demonstrate that you know how to define variables, create conditional statements,...
Write the program in Java. Demonstrate that you know how to define variables, create conditional statements, write a loop, use arrays, obtain input from the user, display output, test and create a JavaDoc. Create project PaystubTest2 that is a Paystub calculator with program Paystub##.java (where ## is your initials) based on user input. (10 points) You must use the ReadStringFromUser and ReadFloatFromUser methods in the program to obtain user input. (20 points) This program will calculate the Gross Earnings, FICA...
PYTHON Part 2 (separate program) Ask for a file name. Don’t let the program crash if...
PYTHON Part 2 (separate program) Ask for a file name. Don’t let the program crash if you enter the name of a file that does not exist. Detecting this will also be discussed on Wednesday. If the file doesn’t exist gracefully display an error message stating the file doesn’t exist and quit the program. It the file does exist read all the values in the file. You will only need to read the file once, or more to the point,...
Goals Practice loops and conditional statements Description Create a game for elementary school students to practice...
Goals Practice loops and conditional statements Description Create a game for elementary school students to practice multiplication. The application should display a greeting followed by a set of mathematical questions.  In each set the player is asked to enter a number from 1 to 9 to test multiplication skills or to press ‘E’ to exit the game.  The application checks if the number entered is indeed between 1 and 9 and if not displays a message inviting the...
In this assignment, you will discuss concepts related to the importance of communication and related concepts...
In this assignment, you will discuss concepts related to the importance of communication and related concepts in the profession of nursing. Follow the instructions below to complete your assignment: Introduce of the concept of communication with a purpose statement Identify and describe the phases of the nurse-patient relationship Evaluate effective and ineffective communication techniques Identify a strategy or strategies to becoming a successful communicator in nursing. Research this topic and integrate a current research article (within the past 5 years)....
Writing a Modular Program in Python In this lab, you add the input and output statements...
Writing a Modular Program in Python In this lab, you add the input and output statements to a partially completed Python program. When completed, the user should be able to enter a year, a month, and a day. The program then determines if the date is valid. Valid years are those that are greater than 0, valid months include the values 1 through 12, and valid days include the values 1 through 31. Instructions Notice that variables have been declared...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT