I have an int array (b[])
with a random length and random integers. I want to leave integers lower than 9 to how they are, i want to change the numbers 9-35
to letters A-Z
. and i want do put ()
around all numbers higher than 35
. So b[] = {1,10,36}
would generate a String 1A(36)
. My try:
int b[] = {99, 2, 3, 4, 5, 10, 35, 24}; //sample input
char[] hilfsarray = new char[b.length];
char[] alphabet = "ABCDEFGHIJKLMNOPQRSTUVW".toCharArray();
for (int k = 0; k < hilfsarray.length; k++) //overwrite all positons with *
hilfsarray[k] = '*';
for (int i = 0; i < b.length; i++) {
int p = b[0] - 10;
if (b[i] < 9 && b[i] <= 35) {
hilfsarray[i] = alphabet[p];
}
return Arrays.toString(hilfsarray);
}