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
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).
Step by Step Solution
3.34 Rating (169 Votes )
There are 3 Steps involved in it
Heres an example of a Java method that meets the requirements youve specif... View full answer
Get step-by-step solutions from verified subject matter experts
