Hello everyone, with this silly question (which I feel I should know, but am having a complete brain meltdown), I need to compare a line of text from one TXT file to another line from another TXT file.
In my assignment, my instructor wants us to create a program that stores account#, first and last names and a balance in a TXT file called "clients", which I did,
100 Alan Jones 348.17
300 Mary Smith 27.19
500 Sam Sharp 0.00
700 Suzy Green -14.22
950 Bob Dylan 25550.00
975 Judy Smith 254.32
985 John Good -56.28
990 Tim Graw 7585.15
also we had to create a transaction TXT file that stores the account# and transaction amount,
950 -126.35
700 -25.52
500 -65.32
985 300.0
990 21.21
and the last thing is to compare the two TXT files using the account# as the key,
this would not be a problem if I was able to modify the transaction TXT file to include the names,
this way I can just compare each line in its entirely. However since I am not allow to include the names,
I need a way to compare just the account#'s and add the transaction amount to the original balance.
This is were my brain has left me and I am drawing a blank on how to accomplish this.
I would put my code here for all to see, but since my brain is blank, I don't have any for this method.
Any suggestions on how to complete this task.
Thanks.
--- Update ---
Just had a thought on how to do this, but would like input if it is the best way or not.
Make two arrayLists from both the trans.txt and clients.txt. This way you can compare cells.
ie:
If cell 0,0 in arraylistTrans = 950, now we can loop through the arraylistClients 0,0 cells, till a match is found, update the balance and store it in the arrayListNewMast.
Once all transactions have been applied, do a for loop to rewrite the arrayListNewMast to a new TXT file call newMast.txt