Question: Hi I m working on a lab in Java and it's called Lab IO. This is how far I got and where I need to

Hi I m working on a lab in Java and it's called Lab IO. This is how far I got and where I need to be:

import java.util.*; import java.io.*; import javax.swing.JOptionPane;

public class LabIO {

private double [][] data;

// rows = data.length; 
// cols = data[i].length; 

public static void main( String [] args )throws IOException

{ LabIO fileTest = new LabIO();fileTest.readData(); System.out.println( fileTest.toString() );fileTest.writeData();

}

public void readData() throws IOException {

Scanner console = new Scanner( System.in ); String outMsg = "Enter the input data filename: "; System.out.println( outMsg ); String inFile = JOptionPane.showInputDialog( outMsg );

File file = new File( inFile ); // connect to the fileScanner tokens = new Scanner( file ); // buffer the data

int nrows = tokens.nextInt(); // get the number of rows. // 1. get the number of cols.

 // 2. allocate space for the 2-d data // 3. write a nested loop to read the // 4. close the file: 
} // end readData() 

public void writeData() throws IOException {

array instance field: data into the data array. 

// 1. prompt the user for a file name to write. // 2. Allocate the file and allow buffering with printf // 3. write the number of rows into the file // 4. write the number of cols into the file

// 5. // //

// 6. // 7. Write your name into the file. // 8. close the file. 

Format the output using format-elements, numbers should be aligned on the decimal point and rounded to 4 digits to the right of the decimal. use a nested loop to write data stored in the data array.

 } // end of writeData } // end class 
Name of txt file: Data.txt
6 4 45.27 89.1 -65.33333 12.0 94.975 -27.678 97.21 -42.3 33.81 -89.8 -123.34 45.6 73.482 18.112 9.7 41.43 -67.545454 73.86 -19.09 5.555 29.3133 -49.7 80.18181 40.229 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!