Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Copy the program RecursionPlay.java to your computer and implement the TBI (To Be Implemented) methods. The output of the program must match the following. 10...9...8...7...6...5...4...3...2...1...BLAST
Copy the program RecursionPlay.java to your computer and implement the TBI (To Be Implemented) methods.
The output of the program must match the following.
10...9...8...7...6...5...4...3...2...1...BLAST OFF! 8 reversed: 8 16 reversed: 61 128 reversed: 821 2048 reversed: 8402 32767 reversed: 76723 2147483647 reversed: 7463847412 2147518614
____________________________________________________________
RecursionPlay.java :
/* * This Java application demonstrates recursion. */ public class RecursionPlay { public static void main(String[] argv) { countdown(10); int[] x = { 8, 16, 128, 2048, Short.MAX_VALUE, Integer.MAX_VALUE }; for (int i = 0; i < x.length; i++) { System.out.print(x[i] + " reversed: "); reverse_digits(x[i]); System.out.println(); } System.out.println(sum(x, 0, 0)); } /* * TBI (To Be Implemented)... * * Starting with parameter n, print n...n-1...n-2... * and print BLAST OFF! when n hits zero. * * Example: countdown(5) * output: 5...4...3...2...1...BLAST OFF! * * @param n an int to countdown from * * implementation note: countdown(int) cannot * contain any repetition control statements */ private static void countdown(int n) { } /* * TBI (To Be Implemented)... * * Print the digits of parameter n reversed. * * Example: reverse_digits(321) * output: 123 * * @param n the int to reverse * * implementation note: reverse_digits(int) cannot * contain any repetition control statements * * implementation note: parameter n cannot be converted * into any type of an object */ private static void reverse_digits(int n) { } /* * TBI (To Be Implemented)... * * Recursive method that calculates the sum * of the elements of an int[]. * * @param x an array-of-int * @param x_i current index into x * @param total current sum of x up to x[x_i] * @return the sum of the elements in an int[] * * implementation note: The number of parameters * and/or their types can be changed, but doing so * may require changing the main() method. */ private static long sum(int[] x, int x_i, long total) { } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started