Problem 1:

For the subway system in C++ City, USA has three fee classifications: student (17 years or less), adult, and senior (65 years old or more). Write a program that counts how many of each fee classification rode the subway on a given day. Assume that the subway conductor has a laptop PC that runs your program. The conductor enters the age of each customer as the subway is under way. Your user instructions tell the conductor to enter a sentinel value of -1 at the end of the day to terminate the entry process for that day. After the sentinel value is entered, the program must display the number of customers in each fee category.

Problem 2:

Write a program that will obtain any two integers between 2 and 10 from the user and display a multiplication table. For example, if the user enters the values 4 and 5, the table would be:

1 2 3 4 5

2 4 6 8 10

3 6 9 12 15

4 8 12 16 20

If the user enters the values 3 and 2, the table would be:

1 2

2 4

3 6

Problem 3:

Please write a program that asks users to input up to 20 positive integers, and then save them into an array. Finds the maximum, minimum and average of the numbers that were entered. You can use -1 to terminate your input.

To find the smallest element in an array, you only need to find the index of the smallest number. You can use the following function to do this.

int index_of_smallest(const int a[], int start_index, int used_size) {

int min = a[start_index], index_of_min = start_index;

for(int i = start_index+1; i < used_size; i++){

if(a[i] < min) {

min = a[i]; index_of_min = i;

}

} return index_of_min;

}

Note that you can write two more functions:

1) One similar to the one that finds the index of smallest number for finding the index of the largest number; and

2) one that computes the average and returns it to the main.

**Subject Computer Science C-Family Programming**