CS 1043  IO and Exceptions. Childress .Lab 11.RAR

CS 1043 IO and Exceptions. Childress .Lab 11

Use “IOLab.java” to do the following: 1. Your finished program must exclude all the throws IOException lines. Remove the throws IOException from the readData first. Don't remove the throws IOExcpetion from the main method until the program is completed and everything else working. 2. Include competent exception handlers for the readData and writeData methods in this assignment. 3. See the example IO programs posted on the course web-site for assistance. 4. The file to read is located on the last page of this document. Copy and paste the data on the last page into a simple text file. 5. The first two entries in the file represent: 1) the number of rows, 2) and the number of columns. Read the remaining numbers from the input file data and fill a two-dimensional array by rows. For example, if the number of rows is 6 and the number of columns is 4, then the next 4 numbers in the input file make up the first row of numbers in your 2-D array. Use a nested loop to fill the 2-D array. 6. Write an instance method and name it toString. This method will return a string containing the 2-D array as a table. Use the String.format( ) method to build your string. The decimal point should be aligned in each column of output. 7. Prompt the user for an output file-name to write. Write the number of rows and columns into the first two lines of the file. The output file name must be different than the input file name. 8. Write the contents of your 2-D data array into the file using the printf method to format your values in a row-column format using format elements. The decimal point should be aligned in each column. Write the data with four digits to the right of the decimal. a. Write your name into the data-file. Submit your data-file to the lab instructor along with your program assignment. 9. Add logic to recover from an exception in the readData method. If the user enters a nonexistent file name, prompt the user for another file name
Powered by