diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/Main.java b/src/Main.java index 930198c..a67af66 100644 --- a/src/Main.java +++ b/src/Main.java @@ -4,12 +4,31 @@ public class Main { public static void main(String[] args) { //TIP Press with your caret at the highlighted text // to see how IntelliJ IDEA suggests fixing it. - System.out.printf("Hello and welcome!"); + System.out.print("Hello and welcome!"); for (int i = 1; i <= 5; i++) { //TIP Press to start debugging your code. We have set one breakpoint // for you, but you can always add more by pressing . System.out.println("i = " + i); } + + if (isUnique("alwgys")) { + System.out.print("The word is unique"); + } else { + System.out.print("The word is not unique!"); + } + } + + public static boolean isUnique(String word) { + for (int i = 0; i <= word.length()-1; i++) { + char a = word.charAt(i); + for(int j = i + 1 ; j <= word.length()-1; j++) { + if (word.charAt(j) == a) { + return false; + } + } + } + return true; } + } \ No newline at end of file