| CSCI A201/A597Homework Assignment 1 (One) Spring 2000 |
Syracuse.java program. Then turn it in on a floppy.
Here's the task summarized again:
Write a program in a file called Syracuse.java that can
be started with two integer values on the command line.
These values define an interval of numbers, so the first
(let's call it n1) has to be smaller
than the second one (call it n2). Your
program will have to go through all those numbers between
n1 and n2 (including
n1 and n2) and compute
the cost of bringing each number to 1 through the iterative
process, then print them (the numbers and their costs). At the end your
program also has to report which of the numbers has the highest cost
and what the cost was. Here's a sample session with the program:
Herec:\>java Syracuse 15 30 15: 17 iterations. 16: 4 iterations. 17: 12 iterations. 18: 20 iterations. 19: 20 iterations. 20: 7 iterations. 21: 7 iterations. 22: 15 iterations. 23: 15 iterations. 24: 10 iterations. 25: 23 iterations. 26: 10 iterations. 27: 111 iterations. 28: 18 iterations. 29: 18 iterations. 30: 18 iterations. Max: 111 iterations, for [27]
n1 and
n2 are 15 and 30, respectively.
No error checking should be done. The user is expected to be program-friendly.