Java: How do I get Java to take every letter before a vowel in a string and move it to the back of the string?
-
Say I have a string named sentence. sentence contains the words "Hello this is computer science" I want Java to take the first word, take every letter before the first vowel in that word and put it behind the word, (hello > elloh). all the words in sentence would look like this: start = "Hello this is computer science" end = "elloh isth is omputerc iencesc" I don't quite know how to proceed with this without using scanners or delimiters. Thats the tough part I think.
-
Answer:
Here's how I'd do it: Split the sentence up into separate words, then run each through a function or method that will take every letter before the first vowel in that word and put it behind the word... You'll also need to make a function or method called isVowel. This should basically just be a switch statement for a,e,i,o,u.. Here's a basis for your function. public string pigLatinSortOf (String str) { //Loop through each letter of string, call is vowel, return string index //Youll need a temp string to hold your stuff, as you cant simply just shift down letters in a string. //take everything from your vowel index down and move to string //add to the end of string everything from index[0] to your vowel index //return new string. } In main just keep adding the strings returned to a final string and output it. Hope this helps! Don't want to give too much away ;P
sidd0123 at Yahoo! Answers Visit the source
Related Q & A:
- How do I get a nice face next to my name instead of a sillhouette?Best solution by Yahoo! Answers
- How do i get my digital camera to work as a Webcam?Best solution by Yahoo! Answers
- How can I get an audio alert when I get a new e-mail?Best solution by Yahoo! Answers
- How can I get a job at a resort for a Summer?Best solution by eHow old
- How do I get my singing voice back after having a cold?Best solution by wikihow.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.