Hello! I'm trying to write a code that counts how many movies a user has seen. There is file with usernames, and according to how many times the username is repeated, the counter grows by 1. in the end that is the number of movies this user saw. If the elemets of the array are not equal i've set the programm to reset the counter and continue from the last position ( to the next user that is). But there is something wrong as always..and i can't figure it out!
Thanks for your help in advance!
Here is the code:
Code:for(q = 0; q < x.length; q++)
{
for(j = 0; j < x.length; j++)
{
if(x[q] == x[j]) {
z++;
}
else if(x[q] != x[j]){
q = 0;
j = 0;
q = q+z;
j = j+z;
z = 0;
}
}
System.out.println("User " + x[q] + " saw " + z + " movies");
}
