I have been bashing away at this for hours and am not making any new ground.
I have to find the employee that is closest to the all the average.
Originally I thought I would just see how far each value was away from the average (eg ageRemainder = averageAge - age), add all of the remainders together for each employee, then organise the results. Then score that is lowest would be the winner. BUT this is discriminatory, especially if I was to add in more catagories with large figures like for an example an income.
SO I then thought that it would be best to find the difference from the average for each employee variable and then rank each employee for that variable. Eg if the average height is 160 cms and Rob is 180cm his score for heightDifference would be 20. I would then find out who had the least difference of height from the average and rank everyone accordingly. I wanted to do this for all the variables.. eg age, income etc.
Finally to add up all the rank scores for each individual and who ever is lowest overall rank score would have the overall closest average.
I have coded the first part with dynamically allocated memory depending on how many employees the user wanted to input. I am up to where it returns the average. But I am damned if I can figure out a good way using code reuse to do this. Which makes me question if I am thinking about this in the totally wrong way. I have been scribbling away pen and paper and have not made any progress in hours.
Hence I though I might come on here to discuss if I am even going about the algorithm in the right way.