import java.io.*;
public class myFLAMES {
public static void main(String args[]) throws Exception
{
DataInputStream input=new DataInputStream(System.in);
int ctr=0;
/* ask for inputs */
System.out.println("Input your name: ");
String name = input.readLine();
System.out.println("Input her name: ");
String sname = input.readLine();
/* hard part -PROCESSING!!!! */
/* we need to compare this two names */
for(i=0;i<name.length();i++)
{
for(j=0;j<sname.length();j++)
{
if(name.charAt(i)==sname.charAt(j))
{
ctr++;
}
}
}
System.out.println("a: "+ctr);
}
}
I need help for counting the number of similarities between the two strings.
Example:
if I entered JUAN, then JUANA.
The answer should be : 5
Because JUAN has 5 characters with JUANA, those are "J","U","A","N","A"
I was able to do that with my code and was correct.
But how will i count "JUANA" similarity with "JUAN"?
The answer should be: 4
because JUANA has 4 characters in common with JUAN and those are "J","U","A","N".
how do I do this? thanks