Hi! I am a beginner to C++ programming and I am completed stumped on one of my homework labs. I will post the homework instructions and what I have done so far. I appreciate any tips or guidance!
Instructions:
1) Use the notepad program to create a payroll file for 20 records as follow: Employee’s First name, Last name, Social Security Number, Hours worked and Hourly rate.
2) Write a C++ program to read this file into your program and do the proper calculation including overtime if any. Overtime is times and half of the pay rate. Deduct 2% for Social Security, 5% retirement plan, 3% Federal tax (total of 10% deduction). Create a report as follow: Last four digit of SSN, Employee’s first initial and last name, Hours worked, Hourly rate, Gross pay, Total deductions, and Net pay. You may have to use “substr” for SSN and Employees first initial.
Make sure you have number of records and thank you note as a summary at the bottom.
What I have done so far:
#include <iostream>
#include <fstream>
using namespace std;
When posting code, please use code tags so that the code is readable
[code]
// code code here
[/code]
The loop to read data from the file isn't right. .eof isn't set at the end of a read but when a read is attempted. Hence the while loop should have the file extraction as the condition - not .eof().
Once you have that sorted and you have tested that you are reading the file data correctly, what other part of the assignment doesn't you understand?