Question

Write a PYTHON program that displays a weekly payroll report. A loop in the program should...

Write a PYTHON program that displays a weekly payroll report. A loop in the program should ask the user for the employee number, gross pay, state tax, federal tax, and FICA withholdings. The loop will terminate when 0 is entered for the employee number. After the data is entered, the program should display totals for gross pay, state tax, federal tax, FICA withholdings, and net pay. Input Validation: ▪ Do not accept negative numbers for any of the items entered. ▪ Do not accept values for state, federal, or FICA withholdings that are greater than the gross pay. ▪ If the sum of state tax + federal tax + FICA withholdings for any employee is greater than gross pay, print an error message and ask the user to reenter the data for that employee.

Homework Answers

Answer #1

ANSWER:

emp_num, gross_pay, state_tax, federal_tax, fica_withholding, net=[],[],[],[],[],[]
total_chk = False
while True:
        if(not total_chk):
            emp = int(input("Enter employee number: "))
            if emp!=0:
                while True:
                    g_pay = int(input("Enter gross pay: "))
                    if g_pay<0:
                        print("Gross Pay can not be negative. Please try again !")
                        g_pay = int(input("Enter gross pay: "))
                    else:
                        break
            else:
                if(len(emp_num)):
                    print("Gross Pay","State Tax", "Federal Tax", "FICA Withholdings", "Net Pay" ,sep=" * ")
                    print(sum(gross_pay),sum(state_tax),sum(federal_tax),sum(fica_withholding),sum(net), sep="     *     ")
                else:
                    print("No data entered")
                    
                break
        state = int(input("Enter state tax: "))
        while True:
            if state<0:
                print("State tax can not be negative. Please try again !")
                state = int(input("Enter state tax: "))
            elif state>g_pay:
                print("State tax can not be more than gross pay. Please try again !")
                state = int(input("Enter state tax: "))
            else:
                break
        federal = int(input("Enter federal tax: "))
        while True:
            if federal<0:
                print("federal tax can not be negative. Please try again !")
                federal = int(input("Enter federal tax: "))
            elif federal>g_pay:
                print("federal tax can not be more than gross pay. Please try again !")
                federal = int(input("Enter federal tax: "))
            else:
                break
        fica = int(input("Enter FICA withholdings: "))
        while True:
            if fica<0:
                print("FICA withholdings can not be negative. Please try again !")
                fica = int(input("Enter FICA withholdings: "))
            elif fica>g_pay:
                print("FICA withholdings can not be more than gross pay. Please try again !")
                fica = int(input("Enter FICA withholdings: "))
            else:
                break
        if(state+federal+fica > g_pay):
            print("Error: sum of federal tax, state tax and Fica withholdings can't be more than gross pay")
            print("Please reenter data for employee with employee number =",emp)
            total_chk=True
        else:
            total_chk=False
            emp_num.append(emp)
            gross_pay.append(g_pay)
            state_tax.append(state)
            federal_tax.append(federal)
            fica_withholding.append(fica)
            net.append(g_pay-state-federal-fica)
            
            

NOTE: The above code is in Python3. Please refer to the attached screenshots for code indentation and sample I/O.

SAMPLE I/O:

1.

2.

Know the answer?
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
Similar Questions
Write a program in C++ coding that asks the user to input an integer between 25...
Write a program in C++ coding that asks the user to input an integer between 25 and 50, inclusive. Utilize a WHILE loop to test for INVALID input. If the input is INVALID, the loop will repeat, and ask the user to try again. The pseudocode looks like this: Prompt user to input an integer between 25 and 50 Accept the input from the user Test for invalid input (HINT: use a while loop and the OR operator with 2...
Write a program that asks the user to input an integer between 25 and 50, inclusive....
Write a program that asks the user to input an integer between 25 and 50, inclusive. Utilize a WHILE loop to test for INVALID input. If the input is INVALID, the loop will repeat, and ask the user to try again. The pseudocode looks like this: Prompt user to input an integer between 25 and 50 Accept the input from the user Test for invalid input (HINT: use a while loop and the OR operator with 2 relational expressions. You...
Write a Python program that reads in the month, day, and year of a date and...
Write a Python program that reads in the month, day, and year of a date and prints it in the dd/mm/yyyy format or mm/dd/yyyy format, the format depending on the user’s preference. The program also prints the message It is a magic date If the product of month and day is equal to the last two digits of the year. For example, April 20 1980 is a magic date because April (numeric value 4) multiplied by 20 is equal to...
Write a program which: Write a program which uses the following arrays: empID: An array of...
Write a program which: Write a program which uses the following arrays: empID: An array of 7 integers to hold employee identification numbers. The array should be initialized with the following values: 1, 2, 3, 4, 5, 6, 7. Hours: an array of seven integers to hold the number of hours worked by each employee. payRate: an array of seven doubles to hold each employee’s hourly pay rate. Wages: an array of seven doubles to hold each employee’s gross salary....
Write a Python program which calculates the average of the numbers entered by the user through...
Write a Python program which calculates the average of the numbers entered by the user through the keyboard. Use an interactive loop and ask the user at each iteration if he/she wants to enter more numbers. At the end dispay the average on the screen. Using built-in library functions for finding average is not allowed. Sample output of the program: Enter a number > 23 More numbers (yes or no)? y Enter a number > 4 Do you have more...
Write a program display the following menu: Ohms Law Calculator 1. Calculate Resistance in Ohms 2....
Write a program display the following menu: Ohms Law Calculator 1. Calculate Resistance in Ohms 2. Calculate Current in Amps 3. Calculate Voltage in volts 4. Quit Enter your choice (1-4) If the user enters 1, the program should ask for voltage in Volts and the current in Amps. Use the following formula: R= E/i Where: E= voltage in volts I= current in amps R= resistance in ohms If the user enters 2 the program should ask for the voltage...
This is a Java program Program Description You work for a local cell phone company and...
This is a Java program Program Description You work for a local cell phone company and have been asked to write a program to calculate the price of a cell phone data plan being purchased by a customer. The program should do the following tasks: Display a menu of the data plans that are available to be purchased. Read in the user’s selection from the menu.  Input Validation: If the user enters an invalid option, the program should display an error...
The following summary data for the payroll period ended December 27, 2015, are available for Cayman...
The following summary data for the payroll period ended December 27, 2015, are available for Cayman Coating Co.:      Gross pay $ 95,000 FICA tax withholdings ? Income tax withholdings 14,710 Group hospitalization insurance 1,930 Employee contributions to pension plan ? Total deductions 27,177 Net pay ? Additional information: For employees, FICA tax rates for 2015 were 7.65% on the first $118,500 of each employee’s annual earnings. However, no employees had accumulated earnings for the year in excess of the $118,500...
For this assignment, you need to submit a Python program that gathers the following employee information...
For this assignment, you need to submit a Python program that gathers the following employee information according to the rules provided: Employee ID (this is required, and must be a number that is 7 or less digits long) Employee Name (this is required, and must be comprised of primarily upper and lower case letters. Spaces, the ' and - character are all allowed as well. Employee Email Address (this is required, and must be comprised of primarily of alphanumeric characters....
Has to be written in C#! Write a program that includes an Employee class that can...
Has to be written in C#! Write a program that includes an Employee class that can be used to calculate and print the take-home pay for a commissioned sales employee. Items to include as data members are employee number, first name, last name, and total sales. All employees receive 9% of the total sales of the month. Federal tax rate is 18%. Retirement contribution is 10%. Social Security tax rate is 6%. Use appropriate constants, design an object-oriented solution, and...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT