Final Examination CS 141 Thursday, December 18, 1997 This is a closed-book, closed-notes examination. There are six problems. Do not spend too much time on any problem. Read them all through first and solve them in the order that allows you to make the most progress. For most of the problems, you need to write a program or a function. You do not need to write comments or include statements. Your program doesn't have to be fancy or user-friendly. You should make it as simple as possible, as long as it does what is required. In each problem, once you have written a function in one part of the problem, you may use the function in another part of the problem. ------------------------------------------------------------------------------ Problem 3 (35 points): A. Write a class called person, with data fields fname, lname and year_born, whose values will be the first and last name of a person and the year that person was born. Look at the other parts of this question to see what else the class should contain. B. Write a member function called age, for person, which takes the current year as input parameter, and returns the age of the person at the end of the current year. C. Write a non-member function (which is not a friend) called sum_age that takes an array of persons, the number of persons in the array, and the current year as input parameters, and returns the sum of the ages of all the persons in the array. D. Write a member function called match, for person, which takes a first name and a last name as input parameters, and returns true if the person has that first and last name, false if not. E. Write a non-member function called add_person (which is not a friend) that takes an array of persons, the number of persons in the array, and another person as input parameters. The function should add the other person to the array if there is nobody in the array with that first and last name, and modify the size accordingly. ------------------------------------------------------------------------------ Problem 4 (20 points): This problem uses the class from problem 2, and may use any of the functions from problem 2. A. Write a class called company, giving it appropriate data fields to represent all the persons in that company (Assume the company will never have more than 100 persons, but might have less). Look at the other parts of this question to see what else the class should contain. ------------------------------------------------------------------------------