Logical Error?

Hi, so the code below is an assignment my professor recently gave me. I turned it in and have received the grade back. It was a 25/30 due to a logical error apparently. The only note on the paper is that there was a logical error and the word READ in red pen right under the "infile.open("Program9.txt");" line. I have stared at my code for a while now trying to understand the logical error my professor is speaking of. I just can't find it.

Can anyone point out to me the logical error within my code? It outputs the proper calculations as far as I can tell.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
int main() 
{
    int faculty = 0;
    double sumOld = 0, sumNew = 0, avgRaise, avgOld, avgNew,  
           salary, oldSalary, newSalary, sumRaise = 0, raise;
    ifstream infile;
    
    cout << fixed
         << showpoint
         << setprecision(2);
    
    infile.open("Program9.txt");
    
    while(!infile.eof())
    {
          faculty++;
          cout << "Faculty number: " << faculty << endl;
          
          
          infile >> salary;
          
          if ( salary > 60000.00)
          {
               oldSalary = salary;
               raise = oldSalary * .04;
               newSalary = oldSalary + raise;
          }
          else if ( salary > 50000.00)
          {
               oldSalary = salary;
               raise = oldSalary * .07;
               newSalary = oldSalary + raise;
          }
          else 
          {
               oldSalary = salary;
               raise = oldSalary * .055;
               newSalary = oldSalary + raise;
          }
          
          cout << "Old Salary: " << oldSalary << endl;
          cout << "Raise: " << raise << endl;
          cout << "New Salary: " << newSalary << endl << endl;
          
          sumRaise = sumRaise + raise;
          sumOld = sumOld + oldSalary;
          sumNew = sumNew + newSalary;
    
    }
    
    infile.close();
    
    avgRaise = sumRaise / faculty;
    avgOld = sumOld / faculty;
    avgNew = sumNew / faculty;
    
    cout << "Sum of Old Salaries: " << sumOld << endl;
    cout << "Sum of New Salaries: " << sumNew << endl;
    cout << "Average of Raises: " << avgRaise << endl;
    cout << "Average of Old Salaries: " << avgOld << endl;
    cout << "Average of New Salaries: " << avgNew << endl << endl;
    
    system("PAUSE");
    return 0;
}


The text file used for the salaries was:

52500.00 64029.50 56000.00 53250.00
65500.00 42800.00 45000.50 68900.00
53780.00 77300.00 54120.25 64100.00
44000.50 80100.20 90000.00 41000.00
60500.50 72000.00



Sorry, it's rather long. Any help would be appreciated. I just can't see where I went wrong.
Maybe because it doesn't handle failure to open the file?
Topic archived. No new replies allowed.