Revert "Delete lab3 directory"

This reverts commit 6fc3cc244e.
This commit is contained in:
Oleksii Aleshchenko 2023-04-04 22:32:00 +03:00
parent 6fc3cc244e
commit 31ba116ad8
8 changed files with 59 additions and 0 deletions

View File

@ -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

View File

@ -0,0 +1 @@
Main.java

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" default="true" project-jdk-name="openjdk-19" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/OperationsStrings.iml" filepath="$PROJECT_DIR$/OperationsStrings.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -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<String> uniqueWords = new HashSet<String>();
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());
}
}
}

BIN
lab3/lab3.pdf Normal file

Binary file not shown.