I made a program that prints out manipulated arrays, I would like to reprint all values in the pass[i] array that has a length equal to 7 but Java seems to only reprint the entire set. I am guessing that I am doing something very wrong with my handling of booleans...
String[] pass = new String[cnt];
int[] range = new int[cnt];
int[] arr = new int[cnt];
boolean valid;
for (int i = 0; i < cnt; i++) {
pass[i] = afname[i] + asname[i];
if (pass[i].length() == 7) {
System.out.println(pass[i]);
valid = true;
} else {
valid = false;
if ((7 - pass[i].length()) >= 3) {
range[i] = (int) Math.pow(10, (7 - pass[i].length())) - 100;
System.out.println(pass[i] + range[i]);
} else {
if ((7 - pass[i].length()) == 2) {
range[i] = 99;
System.out.println(pass[i] + range[i]);
} else {
range[i] = 9;
System.out.println(pass[i] + range[i]);
}
}
}
}
if (valid) {
for (int i = 0; i < cnt; i++) {
System.out.println(pass[i]);
}
}
Aucun commentaire:
Enregistrer un commentaire