Results 1 to 3 of 3
  1. #1
    Teclis is offline Member
    Join Date
    Mar 2011
    Posts
    48
    Rep Power
    0

    Default I don't know why Im getting this error; (calling a method)

    Java Code:
    PitcherData.java:26: readDatabase(java.util.Scanner,java.lang.String,java.lang.String[],java.lang.String[],int[],double[],boolean,double,int,java.lang.String,java.lang.String,int) in PitcherData cannot be applied to (java.util.Scanner,java.lang.String,java.lang.String[],java.lang.String[],int[],double[],boolean,double,int,int,java.lang.String,java.lang.String,int)
          numRecords = readDatabase(scan, sent, pitchNameF, pitchNameL,
                       ^
    1 error
    Java Code:
    import java.util.Scanner;
    
    
    public class PitcherData
    {
    public static void main(String[] args)
       {
    
          final boolean debug = true;
          final String sent = "NoPitcher";
          final int arrSize = 100;
    
          int numRecords = 0;
          int iPos;
          int shutOut = 0;
          String nameF, nameL = " ";
          double era = 0;
    
          Scanner scan = new Scanner(System.in);
    
          String[] pitchNameF = new String[arrSize];
          String[] pitchNameL = new String[arrSize];
          int[] shutOutArr = new int[arrSize];
    
          double[] eraArr = new double[arrSize];
          numRecords = readDatabase(scan, sent, pitchNameF, pitchNameL,
                                    shutOutArr, eraArr, debug, era,
                                    numRecords, arrSize, nameF, nameL, shutOut);
    
    
          printData(numRecords, pitchNameF, pitchNameL, eraArr, shutOutArr);
          sortDatabase(numRecords, pitchNameF, pitchNameL, shutOutArr, eraArr);
          printData(numRecords, pitchNameF, pitchNameL, eraArr, shutOutArr);
          if(scan.hasNext())
          {
             nameF = scan.next();
          }
          else
          {
             System.out.println("Not a name, please try again.");
             System.exit(0);
          }
    
          if(nameF.length() > 20)
          {
             System.out.println("Error: Name too long"
                                + "Quitting program.");
             System.exit(0);
          }
          while(!nameF.equals(sent))
          {
             if(scan.hasNext())
             {
                nameL = scan.next();
             }
             else
             {
                System.out.println("Not a name, please try again.");
                System.exit(0);
             }
    
             if(nameL.length() > 20)
             {
                System.out.println("Error: Name too long"
                                   + "Quitting program.");
                System.exit(0);
             }
    
             if(scan.hasNextInt())
             {
                shutOut = scan.nextInt();
             }
             else
             {
                System.out.println("ERA in invalid format. \n Quitting program.");
    
                System.exit(0);
             }
    
             iPos = seqSearch(numRecords, pitchNameF, pitchNameL, shutOutArr,
                    nameF, nameL, shutOut);
    
             System.out.println("\nIs there a pitcher with a name of " + nameF
                                   + " " + nameL + "\n  and a shutout of "
                                   + shutOut
                                   + " in the database,"
                                   + "\n  and if so, what is their ERA?");
    
             if(iPos > -1)
             {
                System.out.println("Yes. The ERA is " + eraArr[iPos] + ".");
             }
             else
             {
                System.out.println("No, there is no such pitcher"
                                   + "in the database.");
             }
             if(scan.hasNext())
             {
                nameF = scan.next();
             }
             else
             {
                System.out.println("Not a name, please try again.");
                System.exit(0);
             }
    
             if(nameF.length() > 20)
             {
                System.out.println("Error: Name too long"
                                   + "Quitting program.");
                System.exit(0);
             }
          }
       }
       public static int readDatabase(Scanner scan, String sent,
          String[] pitchNameF, String[] pitchNameL, int[] shutOutArr, double[] eraArr,
          boolean debug, double era, int arrSize, String nameF, String nameL,
          int shutOut)
       {
          int numRecords;
          if(pitchNameF.length < arrSize || pitchNameL.length < arrSize
             || shutOutArr.length < arrSize || eraArr.length < arrSize)
          {
             System.out.println("Array's are not of the same length, terminating...");
             System.exit(0);
          }
          if(scan.hasNext())
          {
             nameF = scan.next();
          }
          else
          {
             System.out.println("Not a name, please try again.");
             System.exit(0);
          }
          if(nameF.equals(sent))
          {
             System.out.println("Error: Sentinel rearched before loop.");
             System.exit(0);
          }
    
          if(nameF.length() > 20)
          {
             System.out.println("Error: Name too long"
                                + "Quitting program.");
             System.exit(0);
          }
          while(!nameF.equals(sent))
          {
                   if(scan.hasNext())
             {
                nameL = scan.next();
             }
             else
             {
                System.out.println("Not a name, please try again.");
                System.exit(0);
             }
             if(nameL.length() > 20)
             {
                System.out.println("Error: Name too long"
                                + "Quitting program.");
                System.exit(0);
             }
             if(scan.hasNextInt())
    
             {
                shutOut = scan.nextInt();
             }
             else
             {
                System.out.println("shutOut is incorrect format. \nQuitting program.");
                System.exit(0);
             }
             if(scan.hasNextDouble())
             {
                era = scan.nextDouble();
             }
             else
             {
                System.out.println("era is in inccrrect format. \nQuitting program.");
                System.exit(0);
             }
    
             if(numRecords >= arrSize)
             {
                System.out.println("Array is too small to hold data.");
                System.exit(0);
             }
             else
             {
                eraArr[numRecords] = era;
                pitchNameF[numRecords] = nameF;
                pitchNameL[numRecords] = nameL;
                shutOutArr[numRecords] = shutOut;
                numRecords++;
             }
    
             if(scan.hasNext())
             {
                nameF = scan.next();
             }
             else
             {
                System.out.println("Not a name, please try again.");
                System.exit(0);
             }
    
             if(nameF.length() > 20)
             {
                System.out.println("Error: Name too long"
                                   + "Quitting program.");
                System.exit(0);
             }
          }
          return numRecords;
       }
    
    
    
       public static int seqSearch(int numRecords, String[] pitchNameF,
          String[] pitchNameL, int[] shutOutArr,
          String nameKeyF, String nameKeyL, int shutOut)
       {
    
          int indexFound = -1;
          for(int i = 0; i < numRecords; i++)
          {
             if( pitchNameF[i].equals(nameKeyF) && pitchNameL[i].equals(nameKeyL) && shutOutArr[i] == shutOut)
                   {
                       indexFound = i;
                   }
    
          }
             return indexFound;
       }
       public static void printData(int numRecords, String[] pitchNameF,
          String[] pitchNameL, double[] eraArr, int[] shutOutArr)
       {
          String temp;
          String temp2;
          System.out.println("Print the database:");
          for(int i = 0; i < numRecords; i++)
          {
             temp = pitchNameF[i];
             temp2 = pitchNameL[i];
             while(temp.length() < 15)
             {
                temp = temp + " ";
             }
             while(temp2.length() < 15)
             {
                temp2 = temp2 + " ";
             }
    
             System.out.println("Record Number: " + i
    
                                + " First Name: "
                                + temp + " Last Name: " + temp2
                                + "Shut Out Games: " + shutOutArr[i]
                                + " ERA: " + eraArr[i]);
    
          }
    
       }
       public static void sortDatabase(int numRecords, String[] pitchNameF,
          String[] pitchNameL, int[] shutOutArr, double[] eraArr)
       {
          System.out.println("\nSort the database.\n");
          int smallest; //variable to hold the index of the smallest element
    
          String temp, temp2; //a temporary variable to use when swapping the elements
          int temp3;
          double temp4;
          for(int i = 0; i < numRecords; i++)
    
          {
    
             smallest = i;
    
             for(int j = i; j < numRecords; j++)//loop to find the smallest element
             {
                if(pitchNameL[smallest].compareTo(pitchNameL[j]) > 0)
                   smallest = j;
             }
             temp = pitchNameL[smallest];
             pitchNameL[smallest] = pitchNameL[i];
             pitchNameL[i] = temp;
             temp2 = pitchNameF[smallest];
             pitchNameF[smallest] = pitchNameF[i];
             pitchNameF[i] = temp2;
             temp3 = shutOutArr[smallest];
             shutOutArr[smallest] = shutOutArr[i];
             shutOutArr[i] = temp3;
             temp4 = eraArr[smallest];
             eraArr[smallest] = eraArr[i];
             eraArr[i] = temp4;
            }
    
       }
    }
    As far as I see, their exactly the same and I shouldn't be getting this error.

  2. #2
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    364
    Rep Power
    5

    Default

    Look at your arguments that you are passing in.

    You are passing in 2 integers after your double, and the method you are trying to use only takes 1 integer after the double (too many parameters :))
    Last edited by sehudson; 04-20-2011 at 09:17 PM.

  3. #3
    Teclis is offline Member
    Join Date
    Mar 2011
    Posts
    48
    Rep Power
    0

    Default

    I swear I took that out D: But, you were right; program works like it should.


    Thanks!

Similar Threads

  1. ERROR: Calling array from a method
    By agente47 in forum New To Java
    Replies: 2
    Last Post: 03-25-2011, 04:18 PM
  2. Thread problem, calling method in run method
    By majk in forum Threads and Synchronization
    Replies: 4
    Last Post: 09-27-2010, 12:40 PM
  3. Calling The main method from another method
    By SwissR in forum New To Java
    Replies: 3
    Last Post: 07-27-2010, 12:03 PM
  4. Replies: 29
    Last Post: 09-25-2008, 08:55 PM
  5. Replies: 10
    Last Post: 09-18-2008, 10:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •