Midterm Examination CS 141 Wednesday, April 8, 1998 This is a closed-book, closed-notes examination. There are five 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 each of the problems, you need to write a function. You do not need to write comments or #include statements. Assume that the type bool already exists. Your program does not have to be fancy or user-friendly. You should make it as simple as possible, as long as it does what is required. ------------------------------------------------------------------------------ Problem 1 (25 points): Write a function called sorted, which takes an array of integers and the size of the array as input. The function should return true if the integers in the array are ordered from smallest to largest. Otherwise false. Example ------- The array 5 20 32 33 68 99 is sorted, so return true. The array 5 10 20 30 25 40 is not sorted, so return false. ------------------------------------------------------------------------------ Problem 2 (25 points): Write a function called double_letter that takes two strings as input. The first string will contain a word. The function should make the second string the same as the first string, except that each letter is doubled. Example ------- If the first string is: apple The second string becomes: aappppllee ------------------------------------------------------------------------------ Problem 3 (25 points): Write a function called remove_e that takes an input stream and an output stream as input. Assume that both of these streams are already associated with a file. The function should copy the file associated with the input stream to the file associated with the output stream, except that every occurence of the letter e is removed. (You can assume no capital letters). Example ------- Suppose the input file looks like this (what is inside the stars is the file): ************************************************ * hello everybody. this is just a file that i * * created for this problem. * * * * * * heeeeeeeeeeeeeeeeeere's johnny! * ************************************************ Then the output file will look like this: ************************************************ * hllo vrybody. this is just a fil that i * * cratd for this problm. * * * * * * hr's johnny! * ************************************************ ------------------------------------------------------------------------------ Problem 4 (25 points): Create a class called person containing data fields for first name, last name, an array of five test grades, and a letter grade (S or U). Write a member function for person called assign_grade that assigns the letter grade based on the five test grades. If the average of the test grades is 60 or above then the letter grade is set to S. Otherwise the letter grade is set to U. ------------------------------------------------------------------------------