I can not seem to create an object with the variable from the .txt file, I have it:
< Pre> Import java.io. *; Import java.util. *; Public class main {public static zero main (string [] args) {ArrayList & lt; Employee & gt; ArrEmployee = New Arrestist & lt; Employee & gt; (); // array for employee objects {scanner txtIn = new scanner (new file ("/ user / patrickbui / document / workspace / comp 249 - assignment 3 / src / payroll.txt")); While looping through (// txtIn.hasNext ()) {// payroll.txt file and creating employee numbers for employee items from your data, longer = txtIn.nextLong (); String employee name = txtIn.next (); String Last Name = txtIn.next (); Double hours worked = txtIn.nextDouble (); Double Hourly Access = txtIn.nextDouble (); ArrEmployee.add (new employee (employee number, employee name, last name, hours work, hourly)); }} Hold (FileNotFoundException e) {System.out.println ("Failed to find file payroll"); }}}
So far, I do not know why it may be incorrect that Payroll.txt has been formatted as:
31718 Philip Lannoox 55.0 20.00 11528 Nancy Tropper 40.0 10.45 16783 John Connect 30.5 10.00 10538 Peter Dunken 45.0 10.75 21 o 15 James Harold 32.0 10.50
And when I run the program, I receive these errors I:
Exceptions to the thread "main" java.util.InputMismatchException at java.util.Scanner.throw.Sor (Scanner.java): 864) at java.util.Scanner.next ( Scanner.java 1485) at java.util.Scanner.nextLong Scanner.java 18182) on the main .man (Maine.) Java
Why is this happening? My code looks in the proper order and it is really bothering me.
Your problem is that you have a letter <00>
21015
No comments:
Post a Comment