CSCI A201/A597

Homework Assignment 1 (One)

Spring 2000


Due date
At the end of the lab Jan 27-28
Late policy
Once the solution is posted no submissions are allowed.
Work policy
Working in groups is encouraged but please turn in your own version of the assignment.
Task
Read the lab notes and write the 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:

c:\>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]
Here n1 and n2 are 15 and 30, respectively.
Grading
[1] 10% initializing the range from the command line
[2] 50% correctly computing number of iterations per given number
[3] 10% correctly computing step 2 for each number in the given range
[4] 20% correctly computing the max number of iterations
[5] 10% correctly identifying the number for which this maximum occurs

No error checking should be done. The user is expected to be program-friendly.