There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Your program must ask the user to enter the names of two input files and a single output file
which will contain the merged contents of the two input files. Use dialog boxes to get the
filenames from the user.
Koen Aerts wrote:Get rid of your keyboard1 and keyboard2 Scanners like I mentioned before. Your code first get input from the dialog, then it waits on the console for input again.
brent bynum wrote:
Koen Aerts wrote:Get rid of your keyboard1 and keyboard2 Scanners like I mentioned before. Your code first get input from the dialog, then it waits on the console for input again.
Ok, I did that but I have errors on this line:
Koen Aerts wrote:
brent bynum wrote:
Koen Aerts wrote:Get rid of your keyboard1 and keyboard2 Scanners like I mentioned before. Your code first get input from the dialog, then it waits on the console for input again.
Ok, I did that but I have errors on this line:
Come on, I practically gave the solution already. Change this:
to this:
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Koen Aerts wrote:Your assignment mentions the names in the 2 input files are already sorted. So now you have to iterate through the lines in the 2 input files; for each line you read from the files, you compare them with each other, then write the "smaller" one to the output file.
To compare the 2 strings you could use the compareTo() String method. Each time studentName1 is less than studentName2, you write studentName1 to the output file and break out of the while (inputFile2) loop. Otherwise write out studentName2 to the output file and don't break out of the while (inputFile2) loop.
I was her plaything! And so was this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|