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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
9 changes: 3 additions & 6 deletions src/main/java/MyTasks.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@

public class MyTasks {
public static void main(String[] args) throws FileNotFoundException {
CoreLanguageTasks.ConvertTemperatureFromFahrenheitToCeslius();
CoreLanguageTasks.convertTemperatureFromFahrenheitToCeslius();
System.out.println(CoreLanguageTasks.getGratestValue());
CoreLanguageTasks.iterateAllElements();
CoreLanguageTasks.findLongestWordInFile();
CoreLanguageTasks.writeElementsOfArrUsingPosition();
CoreLanguageTasks.displayDatesWithFormat();

}

static class CoreLanguageTasks {
public static void ConvertTemperatureFromFahrenheitToCeslius() {
public static void convertTemperatureFromFahrenheitToCeslius() {
System.out.println("Vvedit Fahrenheit value: ");
Scanner scanner = new Scanner(System.in);
double fahrenheit = scanner.nextDouble();
Expand Down Expand Up @@ -57,7 +56,6 @@ public static void findLongestWordInFile() throws FileNotFoundException {
Scanner scanner = new Scanner(new File("C:\\Users\\mmazu2\\studying\\text.txt"));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is should be a relative path to the text file. E.g. start with 'System.getProperty("user.dir")' and then put a file destination in the framework

String currentWord;
String checkedWord = "";
//System.out.println(scanner.next());
while (scanner.hasNext()) {
currentWord = scanner.next();
if (currentWord.length() > checkedWord.length()) {
Expand All @@ -67,7 +65,6 @@ public static void findLongestWordInFile() throws FileNotFoundException {
System.out.println("The longest word is:= " + checkedWord);
}

//Write a Java program to print all the elements of an ArrayList using the position of the elements
public static void writeElementsOfArrUsingPosition() {
List<String> strList = Arrays.asList("One", "Two", "Tree", "Four", "London", "Lviv", "1234");
System.out.println("Select elements from ArrList: " + strList);
Expand Down Expand Up @@ -105,4 +102,4 @@ public static void displayDatesWithFormat() {
System.out.println("Bye");
}
}
}
}
Empty file added text.txt

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the file is empty (with no test data). Also, it would be better not to store it in the root of the project but in 'resources' folder

Empty file.