Hello acscicplusplus,
Thank you for using code tags and including the input file.
My first question is how do you know that the file stream is actually open? You have no way to tell. Add this after your open statement:
1 2 3 4 5
|
if (!myemployees)
{
std::cout << "\n File \"" << filename << "\" did not open" << std::endl;
return 1; //exit(1); // If not in "main".
}
|
This will let you know if the file did not open.
Line 25 the while condition is correct, but you are reading to much. You only need to read up to "emptype". Leave reading what is left to the if/else statement.
Line 27 starts reading the second line, but not all the fields.
if (emptype == "H")
now you need to read the hours and pay rate.
The "else if" can just be an "else". You do not need to check if it equals "S". Since you have only two choices if it is not "H" then it must be an "S".
The next problem I see if the else statement is missing the {}s. Only line 37 is part of the else statement. Line 38 although indented does not make it part of the else statement.
When you enter the else statement the first thing you will to do is read the salary amount. Since this is a yearly amount you will need to divide it by 52 to get the weekly amount.
That is what I see for now. After I make the changes and test the program I wil let you know if I find anything else.
Hope that helps,
Andy