I basically have to create a method that takes in a string array and a 2D array consisting of three double arrays and puts the first string with the first array, second string with the second array, etc.
public static void printData(String[] c, double[][] d) {
String cname = "";
for (int i = 0; i < c.length; ++i) {
cname = c[i];
for (int row = 0; row < d.length; ++row) {
for (int col = 0; col < d[0].length; ++col) {
System.out.print(d[row][col] + " ");
}
System.out.println();
}
}
}
Printed out the array a few times
//String word = "";
//for(int i = 0; i < c.length; ++i)
//{
//for(int row = 0; row < d.length; ++row)
//{
//System.out.println();
//for(int col = 0; col < d[0].length; ++col)
//{
//word = c[i];
//System.out.println(d[i][col]);
//}
//}
//}
I did get to the point where I was able to print the city names out with the entire 2D array under them.
To achieve printing each string from the c array with its corresponding double array from the d 2D array on the same line, you should iterate through both arrays simultaneously. Here's how you can modify your method:
This modified method will print each string from the c array along with the values of the corresponding double array from the d 2D array on the same line.