Table 4 Exercises

For these exercises, write code to count names which meet certain conditions and print a line like the following to report the count.

count: 23

The code to produce the above line looks like following, but the real work is in initializing and updating the count variable (or whatever variable you use).

print("count:", count);

The starter code includes the standard count = 0; line to set count to zero before starting.

1. Write code to count and print number of names starting with the letter "O". The last line printed should look like the "count: 23" example above (note: the answer is not 23, that's just a number I made up).


2. Write code to count and print number of girl names starting with "T". The last line printed should look like the "count: 23" example above.


3. Write code to count and print number of boy names ending with "d". The last line printed should look like the "count: 23" example above.


4. (optional) How many names ending in "m" are there with a rank <= 500? Write code to count and print this number. As usual, the last line printed should look like the "count: 23" example above.