Question: Create a package ceRecursion and add a class Recursion. It includes the main method. Include a method hailstone that prints the Hailstone numbers. Its only

  • Create a package ceRecursion and add a class Recursion. It includes the main method.
  • Include a method hailstone that prints the Hailstone numbers. Its only parameter is a number of type int (the seed) and it returns nothing. The seed number needs to be positive. If the client passes a non-positive number, throw an IllegalArgumentException and include a message reminding the user that the seed needs to be positive. How to calculate Hailstorm numbers:
    1. The first number is the seed provided by the client.
    2. Calculate the next number the following way: If the number is even, the next number is half the number otherwise, the next number is three times the number + 1
    3. Repeat 2 until you reach 1 Examples: 3 10 5 16 8 4 2 1 // seed 5 12 6 3 10 5 16 8 4 2 1 // seed 12
  • In the main method, call hailstone four times and pass the values 3, 16, 17, and 24 as arguments. Include a title as shown in the 'Expected Output' section.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!