Welcome to Dream.In.Code
Become a Java Expert!

Join 149,604 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,890 people online right now. Registration is fast and FREE... Join Now!




String class Pig Latin

 
Reply to this topicStart new topic

String class Pig Latin

mezig101
19 Sep, 2007 - 02:05 PM
Post #1

D.I.C Head
**

Joined: 1 Aug, 2007
Posts: 54


My Contributions
Alright I am to write a program that when you enter a sentence it gives you the piglatin of the sentence and the directions for that include

If there are no vowels in the English word, then the Pig Latin word is just the English word + "ay." (There are 10 vowels: 'a,' 'e,' 'i,' 'o,' and 'u,' and their upper-case counterparts.)
Else, if the English word begins with a vowel, then the Pig Latin word is just the English word + "yay."
Otherwise (if the English word has a vowel in it and yet doesn't start with a vowel), then the Pig Latin word is end + start + "ay," where end and start are defined as follows.
Let start be all of the English word up to (but not including) its first vowel.
Let end be all of the English word from its first vowel on.
But, if the English word is capitalized, then capitalize end and "uncapitalize" start.



alright, I have no clue what to do sad.gif

I knooooow how to make the program ask you to enter the sentence but that's about it. How to change it to a piglatin, I have no clue..

so farrr i have
CODE

import java.util.Scanner;
public class Piglatinator
{
    public static void main(String [] args)
    {
        System.out.println("Welcome to the Piglatinator Translator!");
        String str, another = "y";
        
        Scanner scan = new Scanner(System.in);
        
        while(another.equalsIgnoreCase("y"))
        {
            System.out.println("Enter an English phrase: ");
            str = scan.nextLine();
            
            System.out.println();
            
            

            
            
            
            System.out.println("Right another message(y/q)? ");
            another = scan.nextLine();
            
    
    
}
}
}


help plz!!!! oh and I also have a question on reverse recursions..but first I want to get through thisssss..im such a noob sad.gif
User is offlineProfile CardPM
+Quote Post

Gorgi
RE: String Class Pig Latin
19 Sep, 2007 - 03:41 PM
Post #2

New D.I.C Head
*

Joined: 19 Sep, 2007
Posts: 2


My Contributions



CODE

import java.util.Scanner;
public class Piglatinator
{
    public static void main(String [] args)
    {
        System.out.println("Welcome to the Piglatinator Translator!");
        String str, another = "y";
                char vowel[]={'a','e','u','o','i'};
        
        Scanner scan = new Scanner(System.in);
        
        while(another.equalsIgnoreCase("y"))
        {
            System.out.println("Enter an English phrase: ");
            str = scan.nextLine();
                        int a=0;            

            System.out.println();
            
            for(int i=0;i<str.length();i++){
                                a=i+1;
                            if(str.charAt(i)==' '){
                                  for(int j=0;i<vowel.length;j++){
                                       if(str.charAt(a)==vowel[j])
                                         str.charAt(a)=//here u will tipe the letter that you want to stay at the frst place on the word
                            }
            }
            
            
            System.out.println("Right another message(y/q)? ");
            another = scan.nextLine();
            
    //FIRST TRY TO UNDERSTAND THIS CODE
    //IF THIS WILL HELP YOU PLEASE TELL SOME EXAMPS TO WRITE YOUR PROGRAM
}
}
}



This post has been edited by Gorgi: 19 Sep, 2007 - 03:49 PM
User is offlineProfile CardPM
+Quote Post

1lacca
RE: String Class Pig Latin
20 Sep, 2007 - 12:20 AM
Post #3

code.rascal
Group Icon

Joined: 11 Aug, 2005
Posts: 3,822



Thanked: 12 times
My Contributions
If you used the search box of DIC, you would be sooo surprised...
User is offlineProfile CardPM
+Quote Post

mezig101
RE: String Class Pig Latin
20 Sep, 2007 - 01:07 PM
Post #4

D.I.C Head
**

Joined: 1 Aug, 2007
Posts: 54


My Contributions
yea I don't understand the code in the first place..I need help with that..

CODE

for(int i=0;i<str.length();i++){
                                a=i+1;
                            if(str.charAt(i)==' '){
                                  for(int j=0;i<vowel.length;j++){
                                       if(str.charAt(a)==vowel[j])
                                         str.charAt(a);




like why i<str.length()??
and the for loop..im confusedd.. =\
User is offlineProfile CardPM
+Quote Post

KYA
RE: String Class Pig Latin
20 Sep, 2007 - 05:46 PM
Post #5

#include <nerd.h>
Group Icon

Joined: 14 Sep, 2007
Posts: 5,876



Thanked: 159 times
Dream Kudos: 1375
My Contributions
QUOTE(mezig101 @ 20 Sep, 2007 - 02:07 PM) *

yea I don't understand the code in the first place..I need help with that..

CODE

for(int i=0;i<str.length();i++){
                                a=i+1;
                            if(str.charAt(i)==' '){
                                  for(int j=0;i<vowel.length;j++){
                                       if(str.charAt(a)==vowel[j])
                                         str.charAt(a);




like why i<str.length()??
and the for loop..im confusedd.. =\



i<str.length() because that loop runs through the string, through each character and checks it, then taking the first and placing it at the last place, etc...the string is treated somewhat like an array here.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 11:54PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month