I'm trying to make my program write to a file using two methods. It compiles with no errors, but when the file that it wrote to is opened, only coordinates with (0,0) are printed. Its supposed to print 10000 random coordinated from the array. Why does it only print out (0,0) coordinates? Also did I place my return statement in the correct place?
import java.io.*; public class program { public static void main (String [] args) throws IOException { int points = 10000, dimension = 2, lengthA = 100;//int variables are declared and initialized PrintWriter fileOut = new PrintWriter (new FileWriter ("arrayPoints.txt")); double length [] = new double [dimension];//array for length is declared double coordinate [][] = new double [points][dimension];//coordinate array is declared for (int i = 0; i < points; i++){ fileOut.println(java.util.Arrays.toString(coordinate[i])); } fileOut.close();//writes to file }//end main method public static double writeTofile (double length[], double coordinate[][], int points, int dimension, int lengthA) { int x = 0, y = 0; for(int z = 0; z < dimension; z++){//fills the length array with the the set value of lengthA length[z] = lengthA; } for(x = 0; x < points; x++){//runs 1000 times to print 1000 data points for (y = 0; y < dimension; y++){//runs 2 times to print an x and y coordinate coordinate [x][y]= (2 *Math.random() - 1) * length[y];// finds a random number in the range and assiigns it to the coordinate array }//end for }//end for return coordinate[x][y]; }//main method }//program