Ed Buckman

Greenhorn
+ Follow
since Mar 21, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ed Buckman

Ok. I used "||" instead of "|" and Here is the link for the documentation.

For the first part I know if a word starts with a consonant then I cut the first character of the word and put it at the end of the word and to that concatenate "ay" to it. Just cant figure out the code for it.


Oh btw... thanks for all your help guys.
18 years ago
Ok and how would I do that. Keeping in mind I am a complete newbie to java. Also in the original post I said I was having problems with part 2 but its actually part 1 that is tricky:

"If the English word begins with a consonant, move the consonant to the end of the word and add "ay". E.g., the English word "nix" becomes "ixnay" in Pig Latin."
18 years ago
Hey guys, I'm pretty new to java and I am working on a set of problems. The first one is about Pig Latin and I have a little bit of a problem. An IO file is given Here is the question:

------------------------------------------------------------------
Write a program which will ask the user for a single English word and "translate" it into Pig Latin. The rules for this translation are:

* If the English word begins with a consonant, move the consonant to the end of the word and add "ay". E.g., the English word "nix" becomes "ixnay" in Pig Latin.

* If the English word begins with a vowel, simply add "way" to the end of the word. E.g., the English word "apple" becomes "appleway" in Pig Latin.

And the sample runs are:

java PigLatin
clam
The result is lamcay

java PigLatin
oyster
The result is oysterway

java PigLatin
soft-shelled crab
User entered bad input.

java PigLatin
[user types nothing and presses Enter]

User entered bad input.
----------------------------------------------------------

There is an IO.class file that is given with the following methods:

# readString : lets the user enter some text, and returns it as a string
# printString : displays a string result on the screen
# reportBadInput : prints an error message indicating that the user entered a value that makes the program's job impossible.


And my code is:

String str = IO.readString();

if (str.startsWith("a") | str.startsWith("e") | str.startsWith("i") | str.startsWith("o") | str.startsWith("u")){
IO.printString(str.concat("way"));
}
else{
//

}

Now I could do part 1 of the problem but the part 2 is a bit tricky and also I am not sure how to handle bad input. Any help would be greatly appreciated.


Thanks.
18 years ago
Thanks guys... putting static in the main method and also moving the file to the directory defined as classpath helped make this thing run.
Phew... I was about ready to go insane. Love the Ranch
19 years ago
I am a complete newbie... just started working on the Head First Java book and typed up the code on page 60 trying to figure out arrays. The error I get is:
Exception in thread "main" java.lang.NoClassDefFoundError: Dog
What am I doing wrong? It compiled without any errors and when I try to run it this is the error I get. Oh btw here is the code:
[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ March 31, 2004: Message edited by: Dirk Schreckmann ]
19 years ago