Commit 15b08026 authored by louie.bridges's avatar louie.bridges

Update ResitCode.java

parent 668a3213
...@@ -24,20 +24,21 @@ public class ResitCode { ...@@ -24,20 +24,21 @@ public class ResitCode {
public String pigLatin(String message) { public String pigLatin(String message) {
String Newsentence = ""; String Newsentence = "";
//Creates a String array
String[] words; String[] words;
Newsentence = message; Newsentence = message;
words = Newsentence.split(" "); words = Newsentence.split(" ");
String sentence = ""; String sentence = "";
//Creates a for loop that goes through each letter in the sentance
for(String letters : words) { for(String letters : words) {
sentence += letters.substring(1) + letters.substring(0,1) + "ay "; sentence += letters.substring(1) + letters.substring(0,1) + "ay ";
} }
//Removes the space at the end of the sentences
return sentence.trim(); return sentence.trim();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment