Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Help Question A company has 5 categories of employees and pays each as follows: Salaried employees - pay code S or s - Salaried

C++ Help Question

A company has 5 categories of employees and pays each as follows:

Salaried employees - pay code S or s - Salaried employees receive a fixed weekly salary.

Hourly employees - pay code H or h - Hourly employees receive a fixed hourly wage for up to the first 40 hours worked. They receive time and a half (1.5 times their hourly wage) for any overtime hours (hours > 40).

Commissioned employees - pay code C or c - Commissioned employees are paid $400 a week plus 20% of their total weekly sales.

Temporary employees - pay code T or t - Temporary employees are paid a fixed hourly wage (they do not get paid overtime if they work more than 40 hours) plus 15% of their total sales.

Pieceworkers - pay code P or p - Pieceworkers are paid a fixed amount for each item they produce.

Data File

A file contains the data needed to generate the weekly payroll summary. It is made up of several employee records. Each record begins with the employee's identification number (int) and pay code (char), see description of employee categories above. Then, depending on what category an employee is in, the appropriate data will follow. Each data value will be separated by 1 or more blanks.

If the employee is salaried, the amount of his/her weekly salary (double) will be provided. Example: 1005 s 500.00

If the employee is hourly, the number of hours worked (double) followed by the hourly pay rate (double) will be provided. Example: 2017 h 41.0 8.75

If the employee is on commission, his/her sales (double) made for the 5 days of the work week will be provided. Example: 1896 C 100.0 125.0 0.0 157.75 40.0]

If the employee is temporary, his/her hours worked (double) followed by hourly pay rate (double) followed by the total amount of sales (double) will be provided. Example: 2531 T 13.5 7.5 250.0 Page 2/4

If the employee is a pieceworker, the amount paid (double) for an item will be provided, followed by a series of values (int) representing his/her production for the week. The end of the production values will be indicated by a 0. Note: all of the integers indicating number of items produced will be greater than 0 except for the last value (sentinel) which will be a 0. Example: 3149 P 2.25 7 10 18 4 6 11 0 In the example above, the total number of items produced should be 56.

Design a C++ program that will

display your name, lecture section# and lab section #s, assignment #

use named constants to represent fixed values related to commission rates and fixed pay amounts (at least 3)

read the data from the file (via Linux redirection, no prompts)

for each employee

determine how much the employee has earned

display the employee's ID number, category (using a descriptive word), and total earned

The output should be in the form of a table and each column in the table must have a heading. The data in the ID number and category columns must be left justified. The total earned values must be right justified, include a $ and 2 digits to the right of the decimal. Remember to use constants for fixed values.

The program must keep processing employee information until the end of file is encountered.

When all data has been processed, display the total amount earned by all employees as the last line of the table with a suitable label. The final total must be right justified with the amounts above it.

Display messages stating the total number of employees processed and the average amount paid.

Assumptions

No error checking is necessary. All data in the input file will be as described.

ID#s will not exceed 4 digits in length.

The maximum total earnings for all employees will be less than $100,000.00.

Formatting Requirements

Include labels for the 3 columns of the payroll summary.

Left justify ID#s. (maximum length will be 4 digits)

Left justify the category of the employee. Use complete words for the description.

Right justify amount of earnings. Display value with a $ sign and 2 digits to the right of the decimal. Maximum dollar value that program must be able to display (and maintain justification) is $99,999.99.

Words and numbers should not run together. Leave blank lines before and after the payroll summary. Page 3/4

Documentation and Programming Style

Programming assignments will also be evaluated on documentation and programming style.

Make sure your program is properly documented. (15 pts)

comment at start of program file with your name, lecture and lab section #s, assignment #

comments at start of program file that clearly state what the expected input for the program will be and what the expected output will be (be specific)

comments briefly describing named constants and variables (these comments should be placed with the declaration)

Adhere to good programming style. (10 pts)

Make sure that your program is formatted to promote readability. (indent, 1 statement per line, blank lines, etc)

If there are fixed values in the program (values that seldom or never change) declare them as named constants.

Named constants should be declared before the start of the main function.

Variable declarations should be placed inside main at the beginning of the function.

Choose meaningful names for constants and variables within the context of the problem being solved.

Make sure constants and variables are properly described (see Documentation requirements below).

Make sure to include any header files from which library functions will be used.

image text in transcribed

Sample terminal session [joj5@bobby 17FA]$ more data4two 1005 S 500.00 20 h 41.0 8.00 333 t 10.0 5.0 100.0 2109 H 30.0 10.0 4438 p 5.09 124 0 189 C 100.0 125.0 0.0 175.0 100.0 3149 P 2.5 7 10 18 4 6 [joj5@bobby 17FA]:s [joj5@bobby 17FA]$ g++ assign02.cpp [joj5@bobby 17FA]s./a.out

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago