SO I need to make a program to display monthly sales from a file. the files have 10 rows and 8 columns. I created a class that has a constructor that creates a table, merely of the files exact set up. :
public SalesTable(String fileName) {
Scanner theFile = null;
try {
theFile = new Scanner(new File(fileName));
}
catch (FileNotFoundException e) {
System.out.println("File " + fileName + " not found.\n");
System.exit(1);
}
// get variables
myRows = theFile.nextInt();
myCols = theFile.nextInt();
// make table
table = new int[myRows][myCols];
for(int r = 0; r < myRows; r++) {
for(int c = 0; c < myCols; c++) {
table[r][c] = 0;
}
}
for(int r = 0; r < myRows; r++) {
for(int c = 0; c < myCols; c++) {
table[r][c] = theFile.nextInt();
}
}
}
Then in main I call it by SalesTable table = new SalesTable(inFile);
My problem is, is that I need to have it display exactly what was created in the table, but I cannot get it to print the actually digits in the array inside the table.
Any idea what I am doing wrong? thank you in advance!