Hello everyone. This if my first post on the forum, and hopefully my last asking for help on an assignment. I've picked and picked at this, and now I'm going insane. I've edited this one too many times, so now I figure its one of three things. My entire approach to the problem was wrong, my approach wasn't wrong but I went about it the wrong way, or I got it right but my code is messed up somewhere and the entire thing is being throw off.

Anyways, here's 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.

Here's my attempt at coding this. I hope it doesn't look too pathetic.

``````import java.util.Scanner;

public class CoffeeArray
{
public static void main( String args[] )
{

Scanner input = new Scanner( System.in );

int coffee[][];
int aisles;
int weight;
int total[];
int counter;
int number;
int bins;
int totalweight;

System.out.print( "Please input the number of aisles\n" );
aisles = input.nextInt();

coffee = new int [aisles][];

for ( 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] = { {aisles + counter } , {bins} };

}

System.out.print( "How much does each coffee bin weigh?\n" );
weight = input.nextInt();

total[] = { {bins * weight} };

System.out.printf( "%s%10s%10s\n", "Aisles" , "Bins" , "Weight" );
System.out.printf( "%d%10d%10d\n" "Don't know what to put here");

totalweight += total[];

System.out.printf( "The total amount of pounds is: %d" );

}
}``````

Worked on it again and fixed the compiling errors, but now it won't run correctly.

``````import java.util.Scanner;

public class CoffeeArray
{
public static void main( String args[] )
{

Scanner input = new Scanner( System.in );

int coffee[][];
int aisles;
int weight;
int total[];
int counter;
int number;
int bins = 0;
int totalWeight = 0;

System.out.print( "Please input the number of aisles\n" );
aisles = input.nextInt();

coffee = new int [aisles];

for ( 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[aisles];

System.out.printf( "The total amount of pounds is: %d" , totalWeight );

}
}``````

Why not use a class?

class Blah
{
int aisles;
int bins;
}

Then you can store them and access them as objects?