Hello! I am supposed to write a recursive method for my assignment in my class but I'm not sure what is wrong with the code I wrote. The method should print all of the letters of the alphabet up to (including) the parameter value.
Some examples of what it's supposed to do:
printLetters('f')
should return: abcdef
printLetters('D')
should return: ABCD
public class Homework {
public static void printLetters(char c){
char start;
if (c >= 'A' || c <= 'Z')
start = 'A';
else
start = 'a';
while (start <= c){
System.out.print(start);
start++;
}
}
public static void main (String args[]){
printLetters('f');
System.out.println();
printLetters('D');
}
}
Only the second one with D works. The other one print all the characters before it and goes all the way to 'A'
Any ideas???