Here is my assignment.
Ask the user for the number of rows (or aisles of coffee bins). Then prompt the user for the number of bins in each aisle. Create a two dimensional array to correspond to the numbers that the user entered. The array will hold numbers representing pounds. Now prompt the user for the pounds in each bin. Once all the bins are filled, display the each element in the array (in a good format) and display the total number of pounds in the coffee shop.
The program compiles but it isn't working because the array is out of bounds. Am I totally off base, or do I just need to rework what I have?
public class CoffeeArray
public static void main( String args )
Scanner input = new Scanner( System.in );
int bins = 0;
int totalWeight = 0;
System.out.print( "Please input the number of aisles\n" );
aisles = input.nextInt();
coffee = new int [aisles];
if ( counter = 0; coffee.length > counter; counter++)
number = counter + 1;
System.out.printf( "\nHow many bins are in each aisle %d?\n" , number );
bins = input.nextInt();
coffee[aisles] = bins;
System.out.print( "How much does each coffee bin weigh?\n" );
weight = input.nextInt();
total = new int [aisles];
total[aisles] = bins * weight;
System.out.printf( "%s%10s%10s\n", "Aisles" , "Bins" , "Weight" );
System.out.printf( "%d%10d%10d\n" , coffee[aisles], coffee[aisles], total[aisles]);
totalWeight += total;
System.out.printf( "The total amount of pounds is: %d" , totalWeight );