I need to do a problem where i input id, hours worked, pay rate, and age. At the end i need to print id of an employee with the highest pay. I understand how to print highest pay
but how do i assign the id of that same employee to high pay and not the last id i have entered.
1) Line 43,50: When you execute these statements, id has already been replaced by the id of the next employee or -1 (line 37).
2) Line 43,50: You're using highid for two different purposes. At line 43, you're saving the id of the oldest employee. At line 50, you're saving the id of the employee that paid the most tax into the same variable. These are not necessarily the same person.
3) Lines 60-61: You're printing the id of the last employee entered at line 37, which will always be -1 for both lines. As stated in #2, these are not necessarily the same person.
Thank you very much! I finally got it. Just assigned different variable names to two IDs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
cout << ageid << " is the oldest employee, being " << age << " years old" << endl;
cout << taxid << " employee " << "payed the most taxes, equal to $"
<< mosttax << endl;