diff --git a/lab3/OperationsStrings/.idea/.gitignore b/lab3/OperationsStrings/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/lab3/OperationsStrings/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/lab3/OperationsStrings/.idea/.name b/lab3/OperationsStrings/.idea/.name new file mode 100644 index 0000000..002da1d --- /dev/null +++ b/lab3/OperationsStrings/.idea/.name @@ -0,0 +1 @@ +Main.java \ No newline at end of file diff --git a/lab3/OperationsStrings/.idea/misc.xml b/lab3/OperationsStrings/.idea/misc.xml new file mode 100644 index 0000000..7464918 --- /dev/null +++ b/lab3/OperationsStrings/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/lab3/OperationsStrings/.idea/modules.xml b/lab3/OperationsStrings/.idea/modules.xml new file mode 100644 index 0000000..32e9116 --- /dev/null +++ b/lab3/OperationsStrings/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/lab3/OperationsStrings/OperationsStrings.iml b/lab3/OperationsStrings/OperationsStrings.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/lab3/OperationsStrings/OperationsStrings.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/lab3/OperationsStrings/out/production/OperationsStrings/Main.class b/lab3/OperationsStrings/out/production/OperationsStrings/Main.class new file mode 100644 index 0000000..97fa6cc Binary files /dev/null and b/lab3/OperationsStrings/out/production/OperationsStrings/Main.class differ diff --git a/lab3/OperationsStrings/src/Main.java b/lab3/OperationsStrings/src/Main.java new file mode 100644 index 0000000..e4e71f0 --- /dev/null +++ b/lab3/OperationsStrings/src/Main.java @@ -0,0 +1,25 @@ +import java.util.HashSet; + +public class Main { + + public static void main(String[] args) { + String inputText = "Who are you? What is your name? Where are you from?"; + int targetLength = 3; + + try { + HashSet uniqueWords = new HashSet(); + String[] sentences = inputText.split("[?]"); + for (String sentence : sentences) { + String[] words = sentence.trim().split("\\s+"); + for (String word : words) { + if (word.length() == targetLength) { + uniqueWords.add(word.toLowerCase()); + } + } + } + System.out.println("Unique words of length " + targetLength + " in the input text are: " + uniqueWords); + } catch (Exception e) { + System.out.println("An error occurred: " + e.getMessage()); + } + } +} diff --git a/lab3/lab3.pdf b/lab3/lab3.pdf new file mode 100644 index 0000000..12fb76b Binary files /dev/null and b/lab3/lab3.pdf differ