Hello, I tried to solve these problem by myself but I realised that need help. I don't get annything at the output. Will be grateful for any help!
This task have a three condition:
1. Each letter can be used only once.
2.The letter can be used in any order.
3.The text input by the user must not be one of the words generated.
import java.util.Arrays; import java.util.Scanner; public class TYM6 { String[] words = {"and", "love", "vole", "levo", "the"}; // TODO: Read characters from user. // TODO: Loop throgh the words array, and see which words can be made from the user's input. // TODO: Output the words that can be made, one per line. // For the word love program should output: vole, levo public void start1() { Scanner sc = new Scanner(System.in); System.out.print("Enter your characters: "); String chars = sc.nextLine(); String word = Arrays.toString(words); // if(word1.length()) try{ boolean display=true; if(word.length()==chars.length()){ //checking if the length of user input word and words from array are equal for (int c = 0; c<chars.length(); c++) { if (word.indexOf(chars.charAt(c)) == -1) { // Getting character from the list of characters that user typed at position c an search for that character in the //current word display = false; System.out.println("No match"); } } if (display) { System.out.println(word); } } } catch (Exception e) { System.out.println("Couldn't find the list of words!"); } } } public class Main { public static void main(String[] args) { TYM6 tym6 = new TYM6(); tym6.start1(); } }