I have a text file that reads like this:
Department Max
Bob 3 5 6 2 8 F1
Frank 4 8 8 8 8 F2
Jerry 7 9 9 0 9 F3
William 0 0 12 13 14 F2
Buck 3 4 10 8 8 4 6 F4
Greg 1 2 1 4 2 F1
Mike 3 4 4 8 4 F2
While ignoring the name, how do I read these lines and extract these integers as separate ints so I can add them up together?
So far I have this :
for (int i = 0; i < 10; i++) //Loop that checks the employee and their paygrade, 10 times for 10 lines of data
{
getline(inFile, s); //Gets next line in Salary.txt
string payGrade = s.substr(s.length() - 2, 2); //Checks the last two letters of the line to see paygrade
if (payGrade == "F1")
{
auto pos = s.find(' ', s.find('"'));
istringstream iss(s.substr(pos));
F1employeeCounter++;
}
if (payGrade == "F2")
{
F2employeeCounter++;
}
if (payGrade == "F3")
{
F3employeeCounter++;
}
if (payGrade == "F4")
{
F4employeeCounter++;
}
}
Basically I have to check what type of "pay grade" each employee is. There are four different type of pay grades: F1,F2,F3,F4 and each has a different way of paying out the employees based on their hours worked.