This discussion is archived
6 Replies Latest reply: Apr 28, 2008 8:53 PM by 807601 RSS

array required, but int found -- help with my code plz

807601 Newbie
Currently Being Moderated
I keep on getting:
***.java:59: array required, but int found
          wordCount[line]=wordCount;
***.java:58: array required, but float found
          vowelCount[line]=vowelCount;

here is my code: (i'm not looking for a fix, but I'm looking why)

     public static void countWords(String strng) throws IOException
     {
          String changedSent="";
          int spaceCount=0;
          int sp=-1; //used for the location of the space.
          int charCount; //the number of characters.
          int wordCount; //the number of words.
          int averageLetters;
          float vowelCount=0; // the number of vowels
          int counter; // a counter
          
          //tests for spaces
          spaceCount=countChar(' ',strng);
          
          
          //tests for vowels
          System.out.println('a');
          vowelCount=countChar('a',strng);
          System.out.println('e');
          vowelCount=countChar('e',strng)+vowelCount;
          System.out.println('i');
          vowelCount=countChar('i',strng)+vowelCount;
          System.out.println('o');
          vowelCount=countChar('o',strng)+vowelCount;
          System.out.println('u');
          vowelCount=countChar('u',strng)+vowelCount;
          System.out.println("done");
          
          
          wordCount=spaceCount+1; //sets the number of words that there are in the line
          
                    
          
          
          vowelCount[line]=vowelCount;
          wordCount[line]=wordCount;
     }
     public static int countChar(char counted,String strng)
     {
          int totalCount;
          int sp;
          String changedSent;
          
          System.out.println(counted);
          sp=strng.indexOf(counted);
          while (sp != -1) {
               if (totalCount==0) {
                    changedSent=strng.substring(0,sp) + strng.substring(sp+1,strng.length());
                    sp=changedSent.indexOf(counted);
               } else {
                    changedSent=changedSent.substring(0,sp) + changedSent.substring(sp+1,changedSent.length());
                    sp=changedSent.indexOf(counted);
               }
               totalCount=totalCount+1;
          }

          
     }


thanks!