We're asked to program pig Latin, all works fine except for the counting of occurrences of the string.

 public static void count(String [] wordperLine, String [] word){
         String check=" ";
         int count=1;
         for(int i=0; i<=wordperLine.length; i++){
              for(int x=0; x>word[i].length(); x++){
             for(int z=0; z<=word.length; z++){

             if(!word[x].equalsIgnoreCase(check))
             {
                 for(int y=0; y<=word[i].length(); y++){
                 if(word[x].equalsIgnoreCase(word[y]))
                 {
                    count++;
                    check=word[x];
                 }
                }
            }
            System.out.println(word[i]+"-"+count);
        }
    }
}

Just one observation. Why is count initialized to 1 in line 3? I usually start at zero.

Added with edit. Same comment as JamesCherrill. No comments or design notes to decode what this function should do or how.

I have absolutely no idea what that code is supposed to do, and I don't suppose many other people will either. Can you explain what it is supposed to do, maybe with a small example or two of correct input and output?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.