Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Issues In Database Management A Refernce For The Thinking Practitioner

Authors: Fabian Pascal

1st Edition

0201485559, 978-0201485554

More Books

Students also viewed these Databases questions

Question

7. What is coaching? Is there only one type of coaching? Explain.

Answered: 1 week ago