Java I CS 142 Week 03 Assignment.docx

advertisement
Java I CS 142 Week 03 Assignment
Your job will be to:
Note, for this and all future assignments, the primary class should be named “Weeknn.java”, where nn is
a number like 01, 03 (for this week), etc. If other classes are required, the assignment should provide
class names.
Use JOptionPane.showInputDialog() to have the user provide a filename.
(option for extra credit: use JFileChooser, but be sure I can paste in the filespec if I don’t want to click my
way to the file I want in testing).
You may assume that the file to be read is a simple ASCII (Notepad-digestible) file.
Your program will:
Seed the random number generator with a number no one else would think of. That means ensuring
that nobody else will the same random numbers you do, unless by chance they think of the same
number.
Open the file for buffered input.
Open a new file called the input file name.csv For example, if the input file was
“C:\users\dave\documents\demo.txt”, the output file will be “C:\users\dave\documents\demo.txt.csv”
Read the file line – by - line.
For each input line, the output file will have #####,the input line, where ##### is a random int number.
The “#####” represents the output of a nextInt() (?) from the randomizer, and is not necessarily 5 digits
long. It may in fact be negative. Each line gets a random number essentially unpredictable from the
previous line(s).
Close the input and output files.
Display a dialog (JOptionPane.showMessageDialog(null,….) stating that the output file was created and
giving the number of lines in it.
Convince me that you’ve used Eclipse debugger and learned some neat stuff. (How? That’s up to you.
Maybe JOptionPane.showMessageDialog)
Due 90 minutes after class starts on Thursday, January 31st.
Java I CS 142 Week 01 Assignment
p. 1 of 2
Download