[Solved]Java Recall Nifty Sequence Takes Number Even Divide 2 Oddit Multiply 3 Add 1 Discussed Seq Q37078256
In Java Recall the Nifty sequence that takes a number and if itis even it will divide it by 2 and if it is oddit will multiply by3 and add 1. As we discussed before the sequence always seems tohit one at somepoint and then we stop the sequence. This exercisewill take an input number from the user andinstead of just printingthe sequence out it will store the sequence in an array. Since thelength of thesequence differs depending on the first number we willneed to calculate the sequence first to determineits length, thencreate an array of just the right size, and then put the sequenceinto the array.Create a program that does the following.(a) In themain, the program will ask the user for the first number.(b) Themain then will call the method public staticintNiftySequenceLength(intn)that will return the length of thesequence what begins with the numbern.(c) The main then creates thearray of the correct size, loads the first number into the firstpositionand than calls,public static voidPopulateArray(int[]A)which loads the sequence into the array.(d) Finally, have themain call a print array method to print out the array. A run of theprogram is below
.Program Run
Input n: 6
6 3 10 5 16 8 4 2 1
Expert Answer
Answer to In Java Recall the Nifty sequence that takes a number and if it is even it will divide it by 2 and if it is oddit will m… . . .
OR

