Question: Given a positive integer num, the following rules will always create a sequence that ends with 1 , called the hailstone sequence: - If num

 Given a positive integer num, the following rules will always create

Given a positive integer num, the following rules will always create a sequence that ends with 1 , called the hailstone sequence: - If num is even, divide it by 2 - If num is odd, multiply it by 3 and add 1 (i.e. 3 num +1 ) - Continue until num is 1 Write a method, hailstone(0, that takes in a positive integer as a parameter and prints the hailstone sequence starting with that integer. Format the output so that ten integers, each separated by a tab character (\t), are printed per line. Assume the input to the program is always positive. The output format can be achieved as follows: System.out.print(num + "\t"); Ex: If the program input is: 25 the output of method hailstone ( is: Note: Your program must define the method: public void hailstone (int num) 464992.3222280.932947 \begin{tabular}{|l|l|l} LAB & 6.18.1: LAB: Hailstone sequence (EO) & 0/10 \end{tabular} Hailstone.java Load default template

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!