In This Lab You Are Going To Write A Time Card Processor
In This Lab You Are Going To Write A Time Card Processor Program Your
This assignment involves developing a program that reads and processes employee time and sales data from a text file called salary.txt. The program must handle multiple departments, each with its employees across various pay grades—F1, F2, F3, and F4—and compute total salaries, hours, and detailed breakdowns for each department.
The input file begins with a department name, followed by a list of employees with their respective hours or sales data, pay grades, and ends with the marker "EOF". The format of employee data varies based on pay grade:
- F1 and F2: Contain five recorded hours each.
- F3: Contains sales amount and commission percentage, with working hours assumed based on the commission rate (30 hours if ≤10%, otherwise 40 hours).
- F4: Contains seven recorded hours, as they are on-call during weekends.
The pay calculations differ across the pay grades:
- F1: Total hours multiplied by 10.25.
- F2: (Total hours - 35) * 18.95 + 400.
- F3: Total sales amount * commission rate.
- F4: Sum of (first 5 hours 22.55) plus remaining hours 48.75.
The program output should display for each department:
- Department name, total salary, total hours, total number of employees.
- Breakdowns per pay grade: total salary, total hours, number of employees.
The program should be designed with modular functions that handle file reading, data parsing, calculations, and output formatting. Anticipate various data irregularities such as variable number of employees, differing numbers of hours or sales entries, and department name detection. Use string processing functions (like substring) and data type conversions (such as stoi) to parse and process the input data efficiently.
Develop a flowchart to guide the structure of your implementation, outlining the sequence of actions and data flow between functions.
Paper For Above instruction
The development of a time card processor that accurately interprets and calculates employee salaries based on variable input data demonstrates the application of programming principles such as modular design, string parsing, file handling, and conditional logic. The complex nature of this task requires careful anticipation of data irregularities and a systematic approach to parsing, computation, and output formatting.
To efficiently process the salary data, the program should begin with reading the input file, identifying department boundaries, and parsing employee data. Employing functions dedicated to reading lines, extracting employee information, and performing calculations enhances code readability and maintainability. For example, a function like parseEmployeeLine could handle string splitting and data type conversions, while calculateSalary manages pay computations based on pay grade and specific rules.
Handling multiple departments involves detecting department headers—usually containing the word "Department"—and resetting accumulators accordingly. The program must process until the "EOF" marker is encountered, signifying the end of the dataset. This loop continues to handle multiple departments, isolating their data, and summing relevant metrics separately.
The calculation functions vary per pay grade. F1 and F2 involve straightforward arithmetic based on total hours, while F3 requires combining sales data and commission percentage, with an additional assumption about working hours based on commission rate. F4's calculation involves summing multiple hourly entries with different rates. Properly structuring these computations into separate functions prevents errors and makes the code more adaptable.
The output formatting is critical to meet specifications: displaying totals per department and pay grade, clearly labeled, and sorted in a readable manner. Extra features like visual charts or columned output can offer additional insights and are encouraged as bonus work.
Finally, testing with various datasets ensures the program accurately handles different input scenarios, including varying employee counts, department configurations, and data irregularities. Comments and documentation throughout the code improve understandability for future maintenance or enhancements.
References
- Gaddis, T. (2018). Starting Out with Programming Logic and Design. Pearson.
- Deitel, P. J., & Deitel, H. M. (2017). Java: How to program. Pearson.
- Robson, D. (2017). Programming in C. O'Reilly Media.
- Kernighan, B. W., & Ritchie, D. M. (1988). The C Programming Language. Prentice Hall.
- Stroustrup, B. (2013). The C++ Programming Language. Addison-Wesley.
- ISO/IEC. (2014). ISO/IEC 9899:201x Programming languages — C. ISO.
- IEEE Standards Association. (2018). IEEE Standard for Software Verification and Validation.
- Larson, M., & Marx, M. L. (2012). An Introduction to Statistical Learning. Springer.
- McConnell, S. (2004). Code Complete. Microsoft Press.
- Knuth, D. E. (1997). The Art of Computer Programming. Addison-Wesley.