Results 1 to 3 of 3
- 04-20-2011, 07:51 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 48
- Rep Power
- 0
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 errorAs far as I see, their exactly the same and I shouldn't be getting this 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; } } }
- 04-20-2011, 07:58 PM #2
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 08:17 PM.
- 04-20-2011, 08:14 PM #3
Member
- Join Date
- Mar 2011
- Posts
- 48
- Rep Power
- 0
Similar Threads
-
ERROR: Calling array from a method
By agente47 in forum New To JavaReplies: 2Last Post: 03-25-2011, 03:18 PM -
Thread problem, calling method in run method
By majk in forum Threads and SynchronizationReplies: 4Last Post: 09-27-2010, 11:40 AM -
Calling The main method from another method
By SwissR in forum New To JavaReplies: 3Last Post: 07-27-2010, 11:03 AM -
Calling a method in a different class from within a method problem
By CirKuT in forum New To JavaReplies: 29Last Post: 09-25-2008, 07:55 PM -
Why am I getting an error when calling this method?
By CirKuT in forum New To JavaReplies: 10Last Post: 09-18-2008, 09:41 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks