Develop an algorithm to read an arbitrary number of the data records, each consisting of an age, name, and code. A Code of 1 will signify the female, a code of 2 will indicate the male; and a code of 0 will signify that the end-of-file has been achieved. For each record, write down a detail line specifying the person's name and age. Additionally, compute and output the following values: Number of the males less than or equal to the 21 yrs old. Number of the females less than or equal to 21 years old. Average age of all the persons over 21. Total number of the people.