This code is in Java. It allows me to enter the first input fine, but after the second is inputted it keeps looking for more strings, none of the rest of my code follows. Idealy the code will find if 2 strings are anagrams, but I have not been able to test this due to this annoying problem.
import java.util.*;
public class Anagram
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
System.out.println("Please enter a word");
String first = scan.nextLine();
System.out.println("Please enter a second word");
String second = scan.next();
first = first.toLowerCase();
second = second.toLowerCase();
int lengthF = first.length();
int lengthS = first.length();
int x = 0;
int y = 0;
int placeF=0;
int placeS=0;
char g = 97;
int count =0;
if(lengthF != lengthS)
{
System.out.println("The words are not anagrams");
x=1;
}
while(x == y||g<123)
{
x=0;
y=0;
for(int i = 0;i<lengthF;i++)
{
if(first.charAt(i)==g)
{
x++;
}
}
for(int i = 0;i<lengthS;i++)
{
if(second.charAt(i)==g)
{
y++;
}
}
count++;
g++;
}
if(count==23)
System.out.println("Anagram");
else
System.out.println("Not Anagram");
}
}