Question

In: Computer Science

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

Write a 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.

IN PYTHON PLEASE!

Solutions

Expert Solution

Code:

while True:
employeeNumber=int(input("Enter employee number: "))
if (employeeNumber==0):
break
grossPay=float(input("Enter gross pay: "))
if (grossPay<0):
grossPay=float(input("Gross pay should be positive: "))
stateTax=float(input("Enter state tax: "))
if (stateTax<0 or stateTax>grossPay):
grossPay=float(input("State tax should be positive and less than gross pay: "))
federalTax=float(input("Enter federal tax: "))
if (federalTax<0 or federalTax>grossPay):
federalTax=float(input("Federal tax should be positive and less than gross pay: "))
ficaHoldings=float(input("Enter FICA holdings: "))
if (ficaHoldings<0 or ficaHoldings>grossPay):
ficaHoldings=float(input("FICA holdings should be positive and less than gross pay: "))
netPay=grossPay-stateTax-federalTax-ficaHoldings
print("Employee Number: {}".format(employeeNumber))
print("Gross Pay: {}".format(grossPay))
print("State Tax: {}".format(stateTax))
print("Federal Tax: {}".format(federalTax))
print("Net Pay: {}".format(netPay))

  

Screenshot of Code:

Screenshot of Output:


Related Solutions

Using Java, The program you will be writing displays a weekly payroll report. A loop in...
Using Java, The program you will be writing displays a weekly payroll report. A loop in the program should ask the user for the employee’s number, employee’s last name, number of hours worked, hourly pay rate, state tax, and federal tax rate. After the data is entered and the user hits the enter key, the program will calculate gross and net pay then displays employee’s payroll information as follows and asks for the next employees’ information. if the user works...
General Description: Write a program that processes weekly payroll for a small company. The program starts...
General Description: Write a program that processes weekly payroll for a small company. The program starts with printing a logo then asking for the total number of employees for the week. The program then inputs data for each individual employee and prints a paystub. At the end, it prints a report based on data for all employees. Gross Pay: The company has two types of employees: Hourly and Salaried - Hourly employees have an hourly wage, and are paid overtime...
Write a program that uses a while loop with a priming read to ask the user...
Write a program that uses a while loop with a priming read to ask the user to input a set positive integers. As long as the user enters a number greater than -1, the program should accumulate the total, keep track of the number of numbers being entered and then calculate the average of the set of numbers after the user enters a -1. This is a sentinel controlled-loop. Here is what a sample run should look like: Enter the...
Write a Python program that has a loop to continuously ask the user for a number,...
Write a Python program that has a loop to continuously ask the user for a number, terminating the loop when the number entered is -1. Inside the loop, 1.) display one asterisk(*) if the number is 1, 2.) two asterisk(**) if the number is 2 and 3.) "OTHER" if the number is any other number.
Ask the user how many days that they collected gems. A loop you write should loop...
Ask the user how many days that they collected gems. A loop you write should loop how many days the user enters. If the user enters 5 days, then the loop should loop 5 times to collect the data from each day. So, each loop iteration represents a day. In each loop iteration, ask the user how many gems they collected that day. After the loop finishes gathering the data for each day, calculate the total and average gems collected....
C++ while loop Exercise Write a program that continues to ask the user to enter any...
C++ while loop Exercise Write a program that continues to ask the user to enter any set of numbers, until the user enters the number -1. Then display the total sum of numbers entered and their average. (note that you need to define a counter that counts how many numbers so the average = (sum/n) where n is your counter total. #include <iostream> using namespace std; int main() { int number, n=0, sum=0; cout << "Enter a number to start...
Write a program that calculates the area and circumference of a circle. It should ask the...
Write a program that calculates the area and circumference of a circle. It should ask the user first to enter the number of circles n, then reads the radius of each circle and stores it in an array. The program then finds the area and the circumference, as in the following equations, and prints them in a tabular format as shown in the sample output. Area = πr2 , Circumference = 2πr, π = 3.14159 Sample Output: Enter the number...
what should this program do? Write a program (Lab8.cpp) that will ask the user for two...
what should this program do? Write a program (Lab8.cpp) that will ask the user for two file names. You will read the characters from each file and put them in separate queues. Then, you will read each character from each queue and compare it. If every character from both queues is the same, you will print “The files are identical.” Otherwise, you will print “The files are not identical.” Step-by-Step Instructions Create a character queue (named queue1) using the Standard...
Bonus Homework for Week 5 Preparing a Weekly Payroll Report Employee Name Gross Weekly Pay State...
Bonus Homework for Week 5 Preparing a Weekly Payroll Report Employee Name Gross Weekly Pay State Withholding Tax Federal Withholding Tax Net Pay Sue Smith $800 ________________ ________________ Tom Brown $300 ________________ ________________ Mary Wilson $250 ________________ ________________ James Jackson $100 ________________ ________________ John Sinatra $600 ________________ ________________ Betty Rockford $1,255 ________________ ________________ Similar assignment as our in-class IF function work - you must calculate the amount of State Withholding Tax and Federal Withholding Tax. Also calculate Net Pay. Watch-out...
Please use Phyton to write a program: Write a program that calculates and displays the total...
Please use Phyton to write a program: Write a program that calculates and displays the total bill at a restaurant for a couple that is dining. The program should collect from the couple, cost of each meal, and the percentage of the final cost that they would like to tip. The sales tax in the state where the restaurant exists is 7.5%. Display to the user, line by line: Total Cost of Both Meals Sales Tax in dollars Tip in...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT