Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Whats wrong with this Pig Latin code?

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Whats wrong with this Pig Latin code?

    heres my code so far...


    import java.util.StringTokenizer;
     
    public class Piglatin{
     
    public void processLine (Strin line){
    StringTokenizer str = new StringTokenizer(line);
    while (str.hasMoreTokens()){
    String token = str.nextToken();
    String pigToken = this.pigConvert(token);
    finalPigLatinString += " " + pigToken;
    }
    System.out.println(finalPigLatinString);
    }
     
    public String pigConvert(Strign inputToken){
    //this will convert my token to a pig token
    char firstChar = inputString.charAt[0];
    if (isVowel(firstChar)){
    t += token + "ay ";
    // just add 'way' to the word
    }
    else{
    t += token.substring(1,token.length())+firstChar.toString().toLowerCase()+"ay ";
    }
    }
     
    public boolean isVowel (char c){
    //takes in a char and returns true if it is a vowel and returns false if it is not
    if(someChar=='a'||someChar=='e'||someChar=='i'||someChar=='o'||someChar=='u'
    ||someChar=='A'||someChar=='E'||someChar=='I'||someChar=='O'||someChar=='U')
    {
    return true;
    }
    else
    return false;
    }
    }


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Whats wrong with this Pig Latin code?

    Please don't post duplicate threads. I've deleted your other one.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Whats wrong with this Pig Latin code?

    Also, see my signature on asking questions the smart way. You can't simply dump your code here without an explanation and hope for help- what's the problem? Post an SSCCE along with any exceptions or unwanted behaviors you're getting, and we'll go from there. Be specific.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Whats Wrong with this code?
    By whattheeff in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 9th, 2011, 10:59 PM
  2. Whats wrong with my code?
    By whattheeff in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 4th, 2011, 05:34 PM
  3. Whats wrong with my code?
    By mlan in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 27th, 2010, 01:42 PM
  4. i'm new to java. whats is wrong in this code?
    By igorek83 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 30th, 2009, 08:38 PM