Suggested Assignments

1. Write and run a program to print all perfect numbers no greater than n. A number is perfect if it is equal to the sum of its factors; thus 6 is a perfect number (6 = 1 + 2 + 3). The program is to create a collection candidates of all candidates for perfect numbers, remove those that are not perfect from candidates, and print the numbers remaining in it. The program must treat the collection with operations set, insert, omit, and belongs as a data abstraction.

2. Write a program to read in integers, store them in a collection, then read in more integers, remove each of these from it, and finally print all the integers remaining in it. The program is to treat the collection of integers as a data abstraction with the operations of set, insert, omit, and belongs.

3. a. Why does the Bowling Scores program require that the input consist of at least one game?

b. Change the program so that it handles the case of no games as input in a reasonable way.