Write an average-income function | Microsoft Interview Question