Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Answers/40230112126/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Answers/40230112126/.idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions Answers/40230112126/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

406 changes: 406 additions & 0 deletions Answers/40230112126/.idea/dbnavigator.xml

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Answers/40230112126/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions Answers/40230112126/.idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions Answers/40230112126/.idea/libraries/junit_jupiter.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions Answers/40230112126/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions Answers/40230112126/.idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Answers/40230112126/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions Answers/40230112126/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>StringMaster</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>


<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.8.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
63 changes: 63 additions & 0 deletions Answers/40230112126/src/main/java/Advanced.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import java.util.Objects;

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){
sentence = sentence.replace(word, newWord);
return sentence;
}

/**
* In this function You have a firstName and a lastName as Entry and you have to normalize them as a fullName
* @param firstName is a first name with irregular letters (example : hARry)
* @param lastName is a last name with irregular letters (example : pOtTeR)
* @return fullName is a normal full name that just the first letter of firstName & lastName is Capitalized (example : Harry Potter)
*/
public String normalizingName(String firstName, String lastName){
firstName = firstName.toLowerCase();
String firstLetterName = firstName.substring(0,1); //extracting the first word.
firstName = firstLetterName.toUpperCase() + firstName.substring(1);

// first name is uppercase first word + rest of the word.

boolean check = lastName.isBlank();
if (check==false) {
lastName = lastName.toLowerCase();
String firstLetterLastName = lastName.substring(0, 1);
lastName = firstLetterLastName.toUpperCase() + lastName.substring(1);

String fullName = firstName + " " + lastName;
return fullName;
}
else
return firstName;
}

/**
* Removing repeated letter in a word
* @param word This input could have Consecutive repeated letters or not
* @return if word contains Consecutive repeated letters, one of the repeated letters should be omitted
*/
public String doubleChar(String word) {
String answer="";
for (int i=0 ; i<word.length()-1 ; i++){
char previous = word.charAt(i);
char current = word.charAt(i+1);
if(previous!=current)
answer= answer+previous;
else{
continue;
}
}
answer = answer+word.charAt(word.length()-1); //adding the last word.
return answer;
}
}

60 changes: 60 additions & 0 deletions Answers/40230112126/src/main/java/Warmup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
public class Warmup {

/**
* Goal : Simple Introduction To Strings
* In the first function, your inputs are a number and a sentence
* @return is the number th word of the sentence
*/
public String wordFinder(String sentence, int number) {
String[] words = sentence.split(" ");

if (number < 1 || number > words.length) {
String errorPrompt = "Number = " + number + "is out Of Bound";
return errorPrompt;
} else {
return words[number - 1];
}
}
/**
* Goal : Basic introduction to Strings & using foreach
* @param number is in String type
* @param searchForEven is a boolean entry
* @return if searchForEven is true ? return the number of even numbers : return the number of odd numbers
*/
public int oddEvenCounter(String number, boolean searchForEven) {
int odd=0;
int even=0;

for(int i=0; i < number.length(); i++) {
if(number.charAt(i) % 2 == 1)
odd++;
else{
even++;
}
}

if (searchForEven == true)
return even;
else {
return odd;
}
}

/**
* @param wordA --> first word
* @param wordB --> second word
* @return The word that is first in alphabet column
*/
public String firstWord(String wordA, String wordB) {
int result = wordA.compareToIgnoreCase(wordB);
if (result > 0)
return wordB;
else {
if (result < 0)
return wordA;
else {
return "identical words!";
}
}
}
}
Loading