4.23 (Financial application: payroll) Write a program that reads the following information and prints a payroll statement: Employee’s name (e.g., Smith)Number of hours worked in a week (e.g., 10)Hourly pay rate (e.g., 9.75)Federal tax withholding rate (e.g., 20%)State tax withholding rate (e.g., 9%) A sample run is shown below:Enter employee's name: SmithEnter number of hours worked in a week: 10Enter hourly pay rate: 9.75Enter federal tax withholding rate: 0.20Enter state tax withholding rate: 0.09Employee Name: SmithHours Worked: 10.0Pay Rate: $9.75Gross Pay: $97.5Deductions:Federal Withholding (20.0%): $19.5State Withholding (9.0%): $8.77Total Deduction: $28.27Net Pay: $69.22 Requirement: Requirements:  Input and output must match the format provided in the exercise sample runs Currency must be displayed properly: You must have a dollar sign ($) and 2 places after the decimal (dollars and cents) You must use printf rather than the goofy trick from earlier chapters Appropriate selection logic must be used to validate user input. You should enforce the following assumptions: Assumption: all text input is non-empty Assumption: all inputs are non-negative Assumption: there is no overtime pay (hours worked must be no more than 40) Assumption: tax withholding rates are between 0.0 - 1.0 If validation fails for any input: Output a meaningful error message. This isn't shown in the samples, so create your own messages. The messages should indicate the nature of the error/what was expected. Execution must not continue if incorrect input is encountered - use the appropriate method to terminate the program at that point

Question

4.23 (Financial application: payroll)

Write a program that reads the following information and prints a payroll statement:

Employee’s name (e.g., Smith)
Number of hours worked in a week (e.g., 10)
Hourly pay rate (e.g., 9.75)
Federal tax withholding rate (e.g., 20%)
State tax withholding rate (e.g., 9%)


A sample run is shown below:
Enter employee's name: Smith
Enter number of hours worked in a week: 10
Enter hourly pay rate: 9.75
Enter federal tax withholding rate: 0.20
Enter state tax withholding rate: 0.09
Employee Name: Smith
Hours Worked: 10.0
Pay Rate: $9.75
Gross Pay: $97.5
Deductions:
Federal Withholding (20.0%): $19.5
State Withholding (9.0%): $8.77
Total Deduction: $28.27
Net Pay: $69.22

Requirement:

Requirements

  • Input and output must match the format provided in the exercise sample runs
  • Currency must be displayed properly:
    • You must have a dollar sign ($) and 2 places after the decimal (dollars and cents)
    • You must use printf rather than the goofy trick from earlier chapters
  • Appropriate selection logic must be used to validate user input. You should enforce the following assumptions:
    • Assumption: all text input is non-empty
    • Assumption: all inputs are non-negative
    • Assumption: there is no overtime pay (hours worked must be no more than 40)
    • Assumption: tax withholding rates are between 0.0 - 1.0
  • If validation fails for any input:
    • Output a meaningful error message. This isn't shown in the samples, so create your own messages. The messages should indicate the nature of the error/what was expected.
    • Execution must not continue if incorrect input is encountered - use the appropriate method to terminate the program at that point

Expert Answer

Want to see the step-by-step answer?

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.
Tagged in
Engineering
Computer Science

Related Computer Science Q&A

Find answers to questions asked by students like you.

Q: Question: Write a function to display a pattern as follows: 1 2       1 ... ... n       n-1         ...

A: Solution:The python program has the following algorithm:In the displayPattern() function,Declare and...

Q: This is for pygame Text Class The Text class inherits from Drawable and it will be used to display t...

A: Instructions for the Text class:Import the Drawable class and pygame module.Create a class Text and ...

Q: Develop pseudocode for the problem of reading in an arbitrary number of DNA (deoxyribonucleic acid) ...

A: PseudocodeCreate a dictionary data structure to store the DNA base and the complementary base as ser...

Q: Write a program that coverts a zip code to a bar code. The bar codes use large and small bars. We wi...

A: Solution:#Define the functiondef checksum(zip):    #Declare the empty variable    sum = 0    #Loop e...

Q: CHALLENGE 1.24: Read multiple user inputs. ACTIVITY Write two scnr.nextint statements to get input v...

A: Given below is the program to get input values for month and year and write the output value as a mo...

Q: Explain the following error message. $ lsabc abd abe abf abg abh$ rm abc ab*rm: cannot remove ‘abc’ ...

A: “rm” command: This command is used to removes each specified file on the command line.For example, i...

Q: Write a grammar for the language consisting of strings built only of theletters aand b. The strings ...

A: The given language L contains the strings that have infinite number of letters but the strings must ...

Q: This is C++ my programming lab 11.7: Customer AccountsWrite a program that uses a structure to store...

A: Declare the structure Customer_Accounts with the required data fields. Also, declare an array of 20 ...

Q: 5-8) (Find the highest score) Write a program that prompts the user to enter the number of students ...

A: Java program to find the highest score of the student is as follows:

Q: Based on the code that I already have, please help me complete it. I am attempting to use 2 function...

A: Corrections in Program:Add a closing bracket after return statement of main.Remove the parameters fr...

Q: you can allocate up to how many primary partitions on a hard drive

A: A hard drive usually comprises of primary partitions and logical partitions. Primary partition conta...

Q: What values will print? Use Eclipse to verify it but only after you write down youranswers based on ...

A: Description of the Java Math utilities used:-Math.sqrt() returns the square root of its paramter a d...

Q: Transform the grammar with productions S → baAB, A → bAB|λ, B → BAa |A| λ into Chomsky normal form.

A: A context free grammar is in Chomsky normal form if its productions are in the formA → a or A → BC o...

Q: This table is in 1NF. What does the table look like in 3NF? This is about Normalization.

A: First to make the table clears 3NF we need to understand what is Normal form.* Basically normal form...

Q: Register A holds the 8-bit binary 11011001. Determine the B operand and the logic microoperation to ...

A: Selective Complement: this operations complement the bits in register A for which the corresponding ...

Q: Write a GUI application that calculates a car’s gas mileage. The application should let the user ent...

A: Program plan:Test.javaImport the required header filesDefine “Test” classCreate an object for the “M...

Q: How do I get this flat list table into 1NF, 2NF and 3NF?

A: Normalization:Normalization is a process of dividing the tables by more than one idea into set of ta...

Q: A Maze Room : In this lab, we will make a maze game. The maze is based on Linked Lists. Instead of h...

A: For class Room, implement the setter and getter methods by assign and returning values respectively....

Q: Create a trigger called Trig_Enroll_BI on the ENROLLMENT table that fires before an INSERT statement...

A: Solution:Create the trigger with name of “Trig_Enroll_BI” for ENROLLMENT table.The followings algori...

Q: (The Fan class) Design a class named Fan to represent a fan. The class contains:■ Three constants na...

A: Java program to create Fan class is as follows:

Q: 5-1) (Count positive and negative numbers and compute the average of numbers) Write a program that r...

A: Java program to count posive and negative numbers and computing the total and average of numbers is ...

Q: example:"apple->orange->banana->pear"->NULLreturn "orange"Thanks!

A: ApproachIn the function longest(), we'll declare an integer named highestLength and assign 0 to it.N...

Q: What values will print? Use Eclipse to verify it and show the steps. double x = Math.sqrt(4);System....

A: Creating the program exemplifying the Java math operators in a class called MathOperators as shown i...

Q: use java Develop a program which allows the user to enter numbers into an array. Input will be as fo...

A: To develop this program  ,first of all you import  java.util.Scanner package in  which Scanner class...

Q: Construct the XOR operator using only NAND gates. Hint:x XOR y = ((x′y)′(xy′)′)′

A: Drive XOR  operator using only NAND gates:-Let’s assume that the two inputs of NAND and XOR gates  a...

Q: Visual Basic. Write the definition of a function named quadratic that receives three double paramete...

A: Formula for quadratic equation:

Q: I was asked to add the three types of comments to this class, each consisting of the same statement ...

A: Java documentation comment: This comment is used to create documentation API. The syntax for this co...

Q: Financial Application:• Write a program that computes future investment value at a given interest ra...

A: Program plan:Import necessary packages.Define a class named “Investment”.Define a method named “comp...

Q: I need guidance on this, more so what direction do I take to append to a string and make sure it is ...

A: To append the character "D" and "A" into string you can use append(); function of string class.  As ...

Q: How to write a function in python that takes a string s = kkeeepinng and returns the non-repeating c...

A: Program plan:Inside the function, create two empty list named “dup_list[]” and “non_dup_list[]”.Use ...

Q: Not very familiar with RAID so I would really appreciate some help and an explanation behind the ans...

A: RAID is an acronym for Redundant Array of Independent Disk. It is a process of storing the data into...

Q: Design a modular program that asks the user to enter the monthly costs for the following expenses in...

A: We are designing the program in C++ programming language. Given below is the program designed to ent...

Q: In a computer instruction format, the instruction length is 11 bits and the size of an address field...

A: Given:Instruction length = 11 bits = 211 = 2048 bitsAddress register size = 4 bits

Q: This is for python For this assignment, you will write a program to simulate a payroll application. ...

A: Instruction for the given program:Add the given Node class in the python file Node.py.Add the given ...

Q: Read in 5 letters from the keyboard, reverse the order of the second and next to last letters, and p...

A: Pseudocode is an informal approach of programming description that does not need any exact programmi...

Q: 12 4x)x,is an another form of representation of fuzzy set. A, (x) /x, is an another form of represen...

A: A fuzzy set is a pair X, m(A)) where X is a Universal set and mA) is a membership function or degree...

Q: create a python program that will ask users to input four different manufacturers of cars(e.g Ford, ...

A: Create a class Car and define _init_ () function which will initialize the value of variables manufa...

Q: Give regular expressions for the following languages. (a) L1 = {anbm, n ≥ 3, m ≤ 4} (b) L2 = {anbm :...

A: Answer:Regular expression:a. L = {an bm, n >=3, m <= 4}

Q: You are not required to execute the queries. However, your syntax must by accurate.You must give at ...

A: Hey, since there are multiple sub-part questions posted, we will answer first three questions. If yo...

Q: Find context-free grammars for the following languages (with n ≥ 0, m ≥ 0, k ≥ 0):  L = {anbmck, k =...

A: Solution:Given language,L = {anbmck, k = n+m}Consider the “G” as grammar production is given below:

Q: write a program in c++. You work for a box company, and have been asked to write a program to compar...

A: Click to see the answer

Q: write a program to enter two sides a and b of a right triangle from keyboard calculate its area and ...

A: Given below is the C++ program to enter the two sides of a right triangle and then calculate its are...

Q: Write a Python program that allows the user to enter any integer value, and displays the value of 2 ...

A: Given below is the python program that allows the user to enter the value of an integer and displays...

Q: I need help with creating a main.css, I already have the HTML.the details are in the pic and I will ...

A: You can use following code in your main.css file to format your HTML document.Note: Make use of <...

Q: Write a class, AgeMessages , which does the following:a. Ask the user to enter age using a Scannerb....

A: The given below is the code to enter the age through user and print the message according to age. To...

Q: What is the best way to pass 2D arrays to a function? (C++) For my program, I have a 2D array (size:...

A: There are two ways to pass 2-D array to a function either by sending the array name in the function ...

Q: The following print code is to find out the ASCII code, character for the decimal codes,and comparis...

A: The algorithm would involve converting the input integer to character using casting operator as show...

Q: Programming in C

A: We use the bsearch function from the stdlib.h and define a compare function to return the result of ...

Q: Please trace the code and give the correct output

A: Program Instructions:After adding the necessary cstring header file and formatting the output, the p...

Q: The speed of computers has increased greatly over the history of computing. The traveling salesman p...

A: TSP is an NH Hard problem, if solved by brute force method it takes (n-1)! time where n is the size ...