Completed lab is due by: tomorrow at the start of class but see DELIVERABLES below for details of submissions
Use your corrected java program from Lab 3 as your starting point. Be sure to fill in your name in the header and include all appropriate documentation.
REMINDER – Your name must go on all work turned in. This includes hard-copy work as well as electronic files.
Part 1 – Output Files
In the original data files (numbers.txt and numbers2.txt) the input data had one data element per line. In this version, you may not assume that there is only one token per line nor may you assumed that there is any data in the file. (you can try your programs with the old files (somenumbers.txt, nonumbers.txt, empty.txt, oneline.txt) as well as (numbers.txt and numbers2.txt)
1. If you have not already done so alter your program so that you can process multiple tokens per line.
For example:
3 9 3big mayflower
may be on the same line and,
12345
may be the only value on a line.
We will consider the integers goodData is considered the integers and anything else badData. Non-integer data will be string data. Looking at the example above, 3big will be classified as a String, but the 3 and 9 are valid integers to process.
Requirements – Your program should:
§ Echo each line as it is read in.
§ Display each token from the line
§ Echo each token followed by the word integer or String.
2. Compile and test your program using the following 3 input files: input1.dat, input2.dat and input3.dat. Answer Question 1 and 2 on the worksheet that you already saved to your disk..
3. Assume that some potentially badData as well as some goodData will be provided as input to the program.
· You may want to look at Listing 10.7 on pages 547 and 548 for guidance on this part of the lab. TestData.java
· After altering your program so that it will read in each line, echo the data from that line, separate and evaluate the tokens (remember #1 above), you need to send the token to one of two output files. goodData should go to a file called goodDataX.txt while badData should go to a file called badDataX.txt (note: the X should be replaced by the number associated with the input file you are using – for example, if your input file is input1.dat, your output files should be goodData1.txt and badData1.txt). In each of the output files, there should be only one token per line and there should be no blank lines in the file. Be sure to explicitly close each file when finished.
4. Compile and test the program. Print out the files produced.
5. Answer questions 3 – 6 on the worksheet that you already saved to your disk
Part 1 – Working with your “clean” files
6. Now write additional code that will open the file, goodData.txt , as input and will print the following information to the screen with appropriate labels.
§ the min value in the file
§ a count of the number of values in the file
§ the number of times 13 appears in the file.
7. Answer questions 7 – 10 on the worksheet that you already saved to your disk.