So I'm reading in information from a file and getting a type mismatch error. I ran it through the debugger but I'm not sure what's causing it - because it is reading the proper number (in this case, 2000) but it doesn't seem to think it's an integer?
My code is as follows:
public class JobSalaries {
public static void main(String[] args) throws Exception {
final int ARRAY_SIZE = 10;
Employee[] employees2014, employees2015;
int counter2014, counter2015;
File payroll;
payroll = new File("jobpayroll.txt");
employees2014 = new Employee[ARRAY_SIZE];
employees2015 = new Employee[ARRAY_SIZE];
Scanner scan = new Scanner(payroll).useDelimiter(",| ");
counter2014 = 0;
counter2015 = 0;
while(scan.hasNext()) {
int year = scan.nextInt();
String classification = scan.next();
String lname = scan.next();
String fname = scan.next();
int monthlysalary = scan.nextInt();
if(year == 2014 && classification.equals("Employee")) {
String name = fname + " " + lname;
Employee tempemployee = new Employee(name,monthlysalary);
employees2014[counter2014] = tempemployee;
}
}
}
}
And it is reading from this information:
2014 Employee Smith,John 2000
2015 Salesman Jones,Bill 3000 100000
2014 Executive Bush,George 5000 55
2014 Employee Mann,Sarah 4000
2015 Salesman Marco,Jordan 5300 440000
2014 Executive Lance,Tom 1000 60
2014 Employee Gore,Frank 7000
2015 Salesman Madison,Michelle 8000 150000
2014 Executive Berry,Ashley 7600 56
(For simplicity sake, my error is on the line: int monthlysalary = scan.nextInt();)