How to compare 2 chains in java but that 2 words of them are free

0

Good day and thank you very much for your answers in advance.

I have to make a java program that allows me to compare 2 strings (a predefined and correct one) and another that the user will enter, the theme is that in that, say phrase, 2 words must be free (they can vary in length and type of data) that is, the user can put anything that matches or not with what is in the predefined chain but the rest if it should be the same ... I give an example:

Predefined phrase: the forest 3sta very big and dark as well as silent.

Phrase given by the user: the forest 3sta very small and clear as well as silent.

Obsevece how the word "big" and "dark" changed, the result of that comparison is correct since those words are the free ones ...

How can I do it? So far I put both strings in 2 arrays and make the comparison character by character ... The problem comes later with the free words and the text with which the sentence ends.

    
asked by Raymundo Estrada García 22.05.2018 в 17:16
source

1 answer

0

A good time has passed, I do not know if you have solved it but I give you an idea.

String correcta = "el bosque 3sta muy grande y obscuro además de silencioso"
String predifinida[] = correcta.split(" ");

//Aquí deberías de guardar el string que ingrese el usuario
String fraseUsuario = sc.nextLine();
String usuario[] = fraseUsuario.split(" ");

//Lo último que harías sería que compares ambos arreglos. 

Greetings !!

    
answered by 29.07.2018 в 20:09