I am having an issue converting words into phonetic spellings. Example: userInput = apple / outResult = Alpha Papa Papa Lima Echo
I can get my code to convert a single letter to its respective phonetic. I can also get it to split a string into separate characters.
Here is what I have so far....
If a string is entered it will display it separated....
(i.e. apple = a p p l e)
If a single letter is entered....
(i.e. a = Alpha)
I only have letters 'a', 'b', and 'c'...simple reason -- if I can get it to change 'cab' to 'Charlie Alpha Bravo' then I can complete the rest....
on another note I can use a switch statement if possible....not sure how to set that up though.....
I appreciate the help..........
package phonetic;
import javax.swing.JOptionPane;
public class phonetic {
public static void main(String[] args)
{
phoneticAlpha();
}
private static void phoneticAlpha()
{
String userInput;
userInput = JOptionPane.showInputDialog("Enter a word");
char []stringArray;
stringArray = userInput.toCharArray();
for(int i = 0; i < stringArray.length; i++)
System.out.print(stringArray[i] + " "); System.out.print("\n");
if(userInput.equalsIgnoreCase("a"))
{
stringArray.toString();
System.out.println("Alpha");
}
if(userInput.equalsIgnoreCase("b"))
{
stringArray.toString();
System.out.println("Bravo");
}
if(userInput.equalsIgnoreCase("c"))
{
stringArray.toString();
System.out.println("Charlie");
}
}
}