You can better create a Map<Character, String> to save yourself from writing 26 cases on the switch. So you just need to get String for a specific character.
Map<Character, String> mapping = new HashMap<Character, String>(); mapping.put('a', "Alpha"); mapping.put('b', "Beta"); .. And so on..
Of course, you must take the burden of initializing Map , but it will be better than a Mess of switch - case
The advantage is that you can also populate Map from some file .
Then, when you read the character from the scanner, use charAt(0) to extract the first character, because Scanner.next() returns the string: -
letter = kb.next().charAt(0); // Fetch the Phonetic for this character from `Map` phonetic = mapping.get(letter);
source share