Argggg. Stupid tags.... I need to register so I can edit my own posts, this is annoying. Sorry everyone!
Code:
in_data.open("emps.dat");
decimals(cout,2);
while(!in_data.eof())
{
in_data >> temp;
for(i = i; i < 2; i++)
{
max.set_salary(temp.salary());
max.set_name(temp.name());
min.set_salary(temp.salary());
min.set_name(temp.name());
}
if(temp.salary() > max.salary())
{
max.set_salary(temp.salary());
max.set_name(temp.name());
total_sal = total_sal + max.salary();
counter++;
}
else if (temp.salary() < min.salary())
{
min.set_salary(temp.salary());
min.set_name(temp.name());
total_sal = total_sal + min.salary();
counter++;
}
else
{
total_sal = total_sal + temp.salary();
counter++;
}
}
Also, about the for loop. Above in my program I declare i = 1. I found typing the for loop like that was the only way to make it run only 1 time.