Summer 2003 CS0007: Introduction to Computer Programming Project 2: The Hailstone Series |
||||||
|
||||||
Read the entire assignment
before attempting this project. |
||||||
|
||||||
The January 1984 issue of Scientific American contains an article describing an interesting sequence of numbers known as the Hailstone Series. The series is formed like this:
Try this by hand
for a few small numbers and get the idea (note how YOU go into a
loop! For example, start with 9 and write out the sequence. I'll even
give you some space:
|
||||||
|
||||||
You will write a program to generate the Hailstone Series for initial values entered by the user. Your program should answer the following questions after the ground state has been reached:
For example, if 8 is entered as the initial value, then the answer to question #1 is 2 (i.e., it stopped counting when 4 was encountered). Question #2 simply asks you to keep track of the maximum value in the sequence, which is 8 in this small example. Look above at the
sequence you made with the starting value of 9, and answer the two
questions. You should find that there are 18 items in the list, with 52
being the maximum. If you didn't, go back and try it again. If you can't
do these sequences on paper, you'll have a dill of a pickle of a time
writing a program to do it. |
||||||
|
||||||
In a nutshell, your program should begin by asking for a positive integer, and then it should print out the answers to the questions above.
|
||||||
|
||||||
Just a few things:
|
||||||
|
||||||
As usual, copy your source and executable files into the proj2 handin directory. |
||||||
© 2000-2001 University of Pittsburgh |