M
Miggy23
Hello everyone,
I apologize for taking up anyone's time with such a newbie question.
However, my daughter is tearing her hair out over this code. I myself
don't know anything about programming however, being the father that I
am, I am hoping that someone can respond to my plea for help and
provide her with a solution. Below is her code. Thank you all and God
Bless!!
Problem: Print out all the 4 number combinations using only the
following numbers: 6, 9,0,3,1
The code is giving her only 5 combinations at the moment. This is
where she needs help.
//Source code//
import java.math.BigInteger;
public class NumGen {
public static void main(String[] args) {
char[] elements = {'6', '9', '0', '3', '1'};
int[] indices;
CombinationGenerator x = new CombinationGenerator (elements.length,
4);
StringBuffer combination;
while (x.hasMore ()) {
combination = new StringBuffer ();
indices = x.getNext ();
for (int i = 0; i < indices.length; i++) {
combination.append (elements[indices]);
}
System.out.println (combination.toString ());
}
}
}
I apologize for taking up anyone's time with such a newbie question.
However, my daughter is tearing her hair out over this code. I myself
don't know anything about programming however, being the father that I
am, I am hoping that someone can respond to my plea for help and
provide her with a solution. Below is her code. Thank you all and God
Bless!!
Problem: Print out all the 4 number combinations using only the
following numbers: 6, 9,0,3,1
The code is giving her only 5 combinations at the moment. This is
where she needs help.
//Source code//
import java.math.BigInteger;
public class NumGen {
public static void main(String[] args) {
char[] elements = {'6', '9', '0', '3', '1'};
int[] indices;
CombinationGenerator x = new CombinationGenerator (elements.length,
4);
StringBuffer combination;
while (x.hasMore ()) {
combination = new StringBuffer ();
indices = x.getNext ();
for (int i = 0; i < indices.length; i++) {
combination.append (elements[indices]);
}
System.out.println (combination.toString ());
}
}
}