How to move string in visual studio?

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

Was this solution helpful to you?

Just Added Q & A:

Find solution

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.