SO I am having trouble and I feel if I could get past this part I could finish what I am working on. I have the following code which pulls numbers from a file listed in the following order : Employee ID, Wage(Hourly), Hours however I am having trouble assigning variables to this, this would be all I need help with and I would greatly appreciate it.
Please just help me assign variables and I will leave alone I cannot figure out.
PS there are 100 more lines just like that (Different numbers of course). The above code is just me making sure I can read it from the file.
I presume you know how you can read a second line using a loop? Are you aware of the hasNextXXX methods of Scanner? You can use one of them as the continuation condition for a loop.
Does every line of the file contain a int followed by a floating‑point number followed by another int? Did you know you can use a nextXXX method of Scanner to read those data individually?
Did you know things might go horribly wrong if you have an empty line at the end of your file? But you can cross that bridge when you get to it.
Another thing. You must close every Scanner/Reader/Writer/Formatter which does not point to System.in System.out or System.err. Assuming you are using Java7 or Java8 you can use “try with resources” for that. Most probably the best and easiest way to close your Scanner.
Thank you, I forgot to close the file at the end. I fixed that. So the numbers should be teh following;
int, floating, floating. If I remember correclty they should be int, double, double but I am not remembering how to give them the variable names (id,money,h) I do know that I can use has next, but I am still just trying to figure out my variable assignment. BTW, thanks for the welcome to the community.