Once again I am racking my brain as the error messages
keep coming. I am learning how to work with arrays - both regular and multi-dimensioned. I am having problems a) filling the array with the sales data and also with a section where I get the "cannot convert String to an int". When I modify this array to have a string value, - I then get a flip flopped error,- "cannot convert int to String. Any assistance is appreciated. Thanks.
public class Sales{
public static void main (String []Args)
{
//a single dimension array containing the following customer names
String [] Names = {"John Doe","Pete BuysAlot","Joe Stingy","Mary LikesOurStuff" } ;
// for(int 0;i<Names.length; i++)
// System.out.printl=n(Names[i]);}
//a single dimension array containing the names of //each month
String[]Months= new String [11];
Months[0] = " Jan ";
Months[1] = " Feb ";
Months[2] = " Mar ";
Months[3] = " Apr ";
Months[4] = " May ";
Months[5] =" June ";
Months[6] =" July ";
Months[7] =" Aug ";
Months[8] =" Sept ";
Months[9] =" Oct ";
Months[10]=" Nov ";
Months[11]=" Dec ";
// this next section creates the variables and data to create and initialize
// a two dimension array that reflects the purchases each person made per month.
//It will have the initial data in the following table
int[][]slsData = { {200,50,30,300,155,220,80,70,95,110,3,400},
{ 1200,2000,1500,900,1300,800,750,500,900,1200,1500,2000},
{10,0,0,20,5,30,10,0,0,10,15,0},
{500,100,200,400,600,200,150,155,220,336,43 ,455}
};
String [][] slsTablePP = slsData[3][Months]; //here is where an error occurance is. [months] is a declared as a new string array but errors.
{
for (int row = 0; row <Names.length; row++)
for (int col = 0; col<Months.length; col++)
System.out.println(slsTablePP[row][col]); }
// array to hold sales figures totals by month
for( int x=0;x<mthlySales-1;x++)
System.out.println(Names[i] + mthlySls[x]);
}
}
}