In: Computer Science
Each person in the group will be responsible for rewriting the
code to solve one of the original parts
(Alphabetizing 5 words, pig latin, reversing letters, celebrity
names), without using arrays or loops. The purpose of
this assignment is to practice Strings manipulation and String
methods so full credit will only be given if you are utilizing the
code for Strings (substring, charAt, compareTo, equals, etc).
Within the group, you cannot work on the same program so only one
person can submit pig latin, and one person can submit reversing
letters, etc.
English
dog
Apple
easy
Cattle
Remove your old code and replace it with this new code before
testing the program again. Be sure to leave a comment indicating
what you have changed.
(I'm only working on the pig latin option)
Here is the pseudo code for pig latin without array and loop
1. Get the length of the string with length ()
2.converting to lower case as it will be easy to compare to get vowel.
3.getting the index location of each lower case vowel using indexOf ()
5.if no occurrence of vowel means indexOf will return -1.
In order to find the first occurrence of vowel with array or loop, we get the location of every vowel and finding the smallest of five. It gives the first occurance. If the particular vowel is not present -1 will return and it will be the smallest number,in order to avoid that we are adding length +1 to that.
6.find the smallest number of 5 by using math function ,math.min
7.first_ occurance denotes the location of first vowel
8.using subString () we seperate the first vowel occurrence in s1 and remaining string in s2
9.using concat () we append s2 and s1
10.using trim () ,removing whitespace
11.appending "ay" at the end with concat ()
As the programing language is not mentioned ,java is used in the below image