
Patrick B. answered 05/02/20
Math and computer tutor/teacher
import java.io.*;
class AngieARaggedOutput
{
public static void writeToFile( double [][] A, File outputFile)
{
try
{
FileWriter writer = new FileWriter (outputFile);
for (int iLoop=0; iLoop<A.length; iLoop++)
{
String outbuff=" ";
for ( int jLoop=0; jLoop<A[iLoop].length; jLoop++)
{
System.out.print(A[iLoop][jLoop] + " ");
outbuff += A[iLoop][jLoop]+ " ";
}
System.out.println(" ");
outbuff += "\n";
writer.write(outbuff);
} //for iLoop
writer.close();
}//try
catch (IOException ex)
{
}
} //writeToFile
public static void main( String args[])
{
double [][]A = { { 4,6,8,12,16,18,24,28,32,36,42,48,52,56,60,64,68,72,76,80,84,88,92,96,100},
{ 5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100},
{ 4,7,11,13,18,21,23,27,31,37,43,46,49,51,53,57,61,66,69,77,83,91,99},
{ 2.718, 3.142, 3.33, 4.25, 7.11, 13.16, 19.70, 25.57, 35.42, 42.35, 53.27, 69.77}
};
File outfile = new File("doubles.dat");
AngieARaggedOutput x = new AngieARaggedOutput();
x.writeToFile(A,outfile);
}
}