I'm having trouble multiplying the elements of a 2d string array by the element of another. Heres the code:
public static String updateString(String[][] array, String[] prices)
{
String [][] newArray = new String[array.length][];
for(int row = 0; row < prices.length; row++)
{
if (array[row][0].equals(prices[row]))
{
for(int i = 0; row <array.length; row++)
{
newArray[row][i+1] = array[row][i+1] * prices[i+1];
}
}
}
}
Here are what the files look like:
array:
Omaha,104,1218,418,216,438,618,274,234,510,538,740,540
Saint Louis,72,1006,392,686,626,670,204,286,236,344,394,930
Des Moines,116,1226,476,330,444,464,366,230,602,260,518,692
Chicago,408,948,80,472,626,290,372,282,488,456,376,580
Kansas City,308,1210,450,234,616,414,500,330,486,214,638,586
Austin,500,812,226,470,388,488,512,254,210,388,738,686
Houston,454,1086,430,616,356,534,218,420,494,382,476,846
New Orleans,304,1278,352,598,288,228,532,418,314,496,616,882
prices array:
Omaha,7.5
Saint Louis,10.5
Des Moines,8.5
Chicago,11.5
Kansas City,12.5
Austin,10.75
Houston,12.5
New Orleans,9.25
As you can see, the first column of each array lists the city, so if the cities match up, I need the 1st array's elements multiplied by omaha(7.5).