CS 1401, Quiz 9

Date: Tuesday, March 18, 2008
Name (please type legibly, ideally in block letters): ______________________________________________________________________
1. Mark what new material is covered and what is not covered in Chapter 9:

2-4. On this day many centuries ago Ivan the Terrible, a (not very nice) king of Russia, died.

2. Define a class King whose elements are kings. Each king is characterized by his name, the year he became a king, and the year he stopped being a king (e.g., died). Your class should contain a constructor method, accessor methods, mutator methods, and a method for computing the total duration of the king's reign.

3. Use your class in the main method to define an object of type King that corresponds to Ivan the Terrible: his name was Ivan, he started his reign in 1547, and he died in 1584. After defining this object, show how you can change the name to a more correct one "Ivan IV". Compute and print the duration of his reign.

4. Trace your program step-by-step.