diff --git a/Answers/40230212055/Advanced.java b/Answers/40230212055/Advanced.java new file mode 100755 index 0000000..9ae086a --- /dev/null +++ b/Answers/40230212055/Advanced.java @@ -0,0 +1,128 @@ +import java.util.Objects; +import java.util.Scanner; + +public class Advanced { + + /** + * Goal : Changing a Sentence Content + + * In this function, you have a sentence, a word & a newWord as Entry + * You have to search the sentence to find the word that you were given as input and change it with the newWord + + */ + public String wordCensor(String sentence, String word, String newWord){ + + + String[] sentence1 = sentence.split(" "); + + int size = sentence1.length; + + String word1 = word; + + + for(int i =0 ; i first word + * @param wordB --> second word + * @return The word that is first in alphabet column + */ + public String firstWord(String wordA, String wordB) { + + + String string11 =wordA; + String string22 =wordB; + String[] str1 = string11.split(""); + String[] str2 = string22.split(""); + + + int i=0; + int b1=string11.length(); + int b2=string22.length(); + + while(true) + { + /* if (str1[i]=="\0" && str2[i]!="\0") + { + System.out.println(string11); + break; + } + else if (str1[i]!="\0" && str2[i]=="\0") + { + System.out.println(string22); + break; + + } + else + { + System.out.println(string22); + + } +*/ + if ((i)==b1) + { + return (string11); + } + if ((i)==b2) + { + return (string22); + } + + if (str1[i].compareTo(str2[i])<0) + { + + return (string11); + } + + else if (str1[i].compareTo(str2[i])>0) + { + + return (string22); + + } + + else + i++; + + } + + +//tamrin3 + } +} diff --git a/test b/test new file mode 100644 index 0000000..038d718 --- /dev/null +++ b/test @@ -0,0 +1 @@ +testing