|
|
 |
|
|
|
|
b. Determine the week in which the second team sold the most tickets. |
|
|
|
 |
|
|
|
|
c. Determine the week in which the most tickets were sold. |
|
|
|
 |
|
|
|
|
d. Determine the team that sold the most tickets. |
|
|
|
|
|
|
|
|
6. Using the declarations in Exam Preparation Exercise 2, write functions, in proper style, to do the following tasks. Only constants may be accessed globally. |
|
|
|
 |
|
|
|
|
a. Determine which school spent the most money on football. |
|
|
|
 |
|
|
|
|
b. Determine which sport the last school spent the most money on. |
|
|
|
 |
|
|
|
|
c. Determine which school had the most students playing basketball. |
|
|
|
 |
|
|
|
|
d. Determine in which sport the third school had the most students participating. |
|
|
|
 |
|
|
|
|
e. Determine the total amount spent by all the schools on volleyball. |
|
|
|
 |
|
|
|
|
f. Determine the total number of students who played any sport. (Assume that each student played only one sport.) |
|
|
|
 |
|
|
|
|
g. Determine which school had the most students participating in sports. |
|
|
|
 |
|
|
|
|
h. Determine which was the most popular sport in terms of money spent. |
|
|
|
 |
|
|
|
|
i. Determine which was the most popular sport in terms of student participation. |
|
|
|
|
|
|
|
|
7. Given the following declarations |
|
|
|
 |
|
|
|
|
const int NUM_DEPTS = 100;
const int NUM_STORES = 10;
const int NUM_MONTHS = 12;
typedef int SalesType[NUM_STORES][NUM_MONTHS][NUM_DEPTS]; |
|
|
|
 |
|
|
|
|
write a C++ function to initialize an array of type SalesType to 0. The constants NUM_STORES, NUM_MONTHS, and NUM_DEPTS may be accessed globally. The array should be passed as a parameter. |
|
|
|
|
|
|
|
|
8. Sales figures are kept on items sold by store, by department, and by month. Write a C++ function to calculate and print the total number of items sold during the year by each department in each store. The data are stored in an array of type SalesType as defined in Programming Warm-Up Exercise 7. The array containing the data should be passed as a parameter. The constants NUM_STORES, NUM_MONTHS, and NUM_DEPTS may be accessed globally. |
|
|
|
|
|
|
|
|
9. Write a C++ value-returning function that returns the sum of the elements in a specified row of an array. The array, the number of filled-in columns, and which row is to be totaled should be passed as parameters. |
|
|
|
|
|
|
|
|
1. A group of playing cards can be represented as a two-dimensional array, where the first dimension is rank and the second dimension is suit. Read in a bridge hand (13 cards) and determine whether the player should pass or bid. Each card should be input on a line by itself, with the suit given first and the rank next. |
|
|
|
 |
|
|
|
|
The decision to pass or bid is based on the number of points the hand is worth. Points are counted as follows: |
|
|
|
 |
|
|
|
|
An ace is worth 4 points.
A king is worth 3 points.A queen is worth 2 points.
A jack is worth 1 point. |
|
|
|
|
|