Write a Java method with the following header: public static void numbers (String prefix, int n) The

Question:

Write a Java method with the following header:

public static void numbers

(String prefix, int n)

The number k is non-negative. The argument called prefix is a String of 0s and 1s. The method prints a sequence of binary numbers. Each output number consists of the prefix followed by a suffix of exactly k more binary digits (0s or 1s). All possible combinations of the prefix and some k-digit suffix are printed. As an example, if the prefix is the string 00101 and the number of levels is 2, then the method would print the prefix followed by the four possible suffixes shown here:

0010100
0010101
0010110
0010111

The stopping case occurs when k reaches zero (in which case the prefix is printed once by itself followed by nothing else).

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: