Hello there. i need some help finishing up my pig latin translator program. It compiles fine, but when i run it and try to translate a sentence, it gives me a syntax error and i cannot see the error. i am almost done with it, please help!
Code:
import java.io.*; import java.util.*; import java.lang.String; public class IgLatinPay { public static void main(String [] args) { String temporary = " "; String piglatin = " "; Scanner input = new Scanner(System.in); System.out.println("Enter sentence that you want to translate: "); String english = input.nextLine(); while(english.indexOf(' ') != -1) { temporary=english.substring(0,english.indexOf(' ')); english=english.substring(english.indexOf(' ')); if(temporary.charAt(0)=='a' || temporary.charAt(0)=='e' || temporary.charAt(0)=='i' || temporary.charAt(0)=='o' || temporary.charAt(0)=='u') { piglatin=temporary+"way"; System.out.println(piglatin); } else { char firstChar = temporary.charAt(0); piglatin=temporary.substring(1,temporary.indexOf(' '))+ firstChar +"ay"; System.out.println(piglatin); } piglatin+=temporary+" "; } } }
Comment