Write the function WordCount whose header is given below. WordCount returns the number of occurrences of word in Vector list. For example, the call WordCount(list,"dog",8) should evaluate to 2 since "dog" appears twice in list as shown below.
"bird" | "cat" | "dog" | "bird" | "cat" | "mouse" | "bird" | "dog" |
Part B(6 points)
Write the function ModalValue whose header is shown below. ModalValue returns the string that occurs most frequently in its parameter list. If there are ties, i.e., more than one string occurs most frequently, return any maximally occurring string. For example, if list is the array shown on the previous problem, the call ModalValue(list,8) should return "bird" since bird occurs more often than any other string in list. In writing ModalValue you can call function WordCount from part A. Assume that WordCount works as specified regardless of what you wrote for part A.
. | . | . | . | . | . |
. | H | I | . | J | . |
. | . | . | . | O | . |
. | . | . | . | E | . |
. | M | Y | . | . | . |
. | . | . | . | A | T |
Part A (4 points)
Write the function RowSpaceCount that determines the number of spaces (indicated by the character '.') in the row specified by parameter row. For example, the call RowSpaceCount(mat,0,6) should return 6 since there are six spaces ('.') in the row with index 0 and the call RowSpaceCount(mat,2,6) should return 5 since there are five spaces in the row with index 2.
Complete RowSpaceCount below.
Part B: (4 points)
Write a function TotalSpaceCount that returns the total number of spaces ('.') in a matrix. The call TotalSpaceCount(mat,6,6) should return 27 since there are 27 spaces in the matrix shown above. In writing TotalSpaceCount you can call the function RowSpaceCount from part A. Assume that RowSpaceCount works as specified regardless of what you wrote in part A.
Part C: (8 points) Write the function ReflectDiagonal whose header is given below. ReflectDiagonal reflects the elements in a ``down-right'' diagonal of a square matrix. In a square matrix, a down-right diagonal (in the direction: \) can be specified by the top-left row and column of the diagonal one of which must be 0. A down-right diagonal is reflected in the up-left main diagonal / shown in the diagram below on the left as a dotted line. For example, given the matrix on the left below, the call ReflectDiagonal(mat,0,1) yields the matrix shown in the middle and the call ReflectDiagonal(mat,0,0) yields the matrix on the right. The down-right diagonals reflected are shown in each matrix.
Part D: (4 points)
Write the function ReflectAll that reflects all diagonals that start in either the row with index 0 or the column with index 0. For example, the call ReflectAll(mat) where mat is shown on the left yields the matrix on the right. In writing ReflectAll you may call function ReflectDiagonal from part B. Assume that ReflectDiagonal works as specified regardless of what you wrote for Part C.
|
|
You MAY use an auxiliary vector to do the expansion.
054-133-1234 3.25 123-199-6660 2.55 054-133-1234 2.75 123-199-6660 5.55 939-939-9339 0.15 123-199-6660 1.00 054-133-1234 2.75
When run the output should be a list of social security numbers with the total flex expenses for each number.
054-133-1234 8.75 123-199-6660 9.10 939-939-9339 0.15Consider the class FlexAccounts shown below and the client/user program given in main to process all flex accounts in the file ssn. The program is complete except for the member functions ReadData and Next which you will write. Account information is stored in a Vector myList of structs, where each struct stores a social security number and expenses.
Part A: (2 points)
Complete the function FlexAccounts::Next() so that it works as specified. Write code for the body of the function above.
Part B: (8 points)
Complete the member function FlexAccounts::ReadData()} so that it processes all the data in the file specified by the parameter filename. Currently the function reads all the data, but doesn't store the data anywhere. Use the space on the previous page.
Part C: (2 points)
Describe what changes are necessary to print the list expenditures sorted in numerical order by social security. You do NOT need to write code, you just need to describe how to generate output in sorted order.