My professor asked us to generate this output:
A1 B2 C3 D4 E5
F6 G7 H8 I9 J10
K11 L12 M13 N14 O15
P16 Q17 R18 S19 T20
U21 V22 W23 X24 Y25
Z26
I got the correct output but he won't accept my code; he said I have to do it without using an array and using only 2 loops. I can't think of any solutions that can generate the same output. I am wondering if it is possible to make the same output with only 2 loops? I made my code like this but my professor said I have to revise it.
public class lettersAndNumbers {
public static void main(String[] args) {
// TODO Auto-generated method stub
String[] abc = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",
"S", "T", "U", "V", "W", "X", "Y", "Z", };
int i = 0;
while ( i < abc.length ) {
int j = 1;
while ( j <= 26 ) {
int k = 1;
while ( k <= 5 ) {
System.out.print(abc[i] + j + "\t");
j++;
i++;
k++;
if ( k == 6 ) {
System.out.println();
}
}
k = 1;
}
}
}
}