Print the elements of an array into a table I am trying to print the elements of an array into a table, but I'm having trouble formatting the array elements itself.  Perhaps there is a better solution than what I'm currently using?

import java.util.Scanner;
public class RainFall{

  public static void main(String args[]) {
    //create rainfall array
    double[][]rainfall = new double[2][3];
    double sum = 0;
    double average = 0;
    int count = 0;

    Scanner in = new Scanner (System.in);

    System.out.println("Please enter rainfall for Region 1 and Region 2 one after the other");
    //Create For loop to read in data
    for(int i=0;i&lt;rainfall.length;i++){
      for(int j=0;j&lt;rainfall[0].length;j++){
        System.out.println("Enter rainfall:: ");
        rainfall[i][j]=in.nextDouble();
      }
    }
    //create for loop to sum rainfall
    for (int i=0; i &lt; rainfall.length; i++){
      for (int j=0; j &lt; rainfall[0].length; j++){
        sum += rainfall[i][j];
        count++;
      }//end nested for
     }//end outer for

    //calculate average
    average = sum/count;
    //Print table
    System.out.printf( "%5s %10s %15s %20s %25s %n", "Region 1"," Jan", "Feb", "Mar", "Avg Rainfall");
    System.out.printf( "%d", rainfall[0][0] );

    //Print average

    System.out.println("The average rainfall is: " + average);
  }
}
If the array bounds are fixed, then there's no need for the count variable, since its value will always be the same. There's also no need to run a separate loop for the summation. You can do this at the same time as you're gathering the input. And since your output shows that you want to show the averages by region, you'll need to have somewhere to store those values, too.

Also, try using more descriptive prompts for the user so they know how many inputs are expected.

So the first part of your function becomes

//could also define these as constants
int regions = 2;
int months = 3;
int count = regions * months;

double[][]rainfall = new double[regions][months];
double[] avgByRegion = new double[regions];
double sum = 0;
double average = 0;

Scanner in = new Scanner (System.in);

//Create For loop to read in data
for(int i=0; i &lt; regions; i++){
  double sumByRegion = 0;
  for(int j=0; j &lt; months; j++){
    System.out.printf("Enter rainfall for Region %d, Month %d:: ", i+1,j+1);
    rainfall[i][j]=in.nextDouble();
    sumByRegion += rainfall[i][j];
  }
  avgByRegion[i] = sumByRegion/months;
  sum += sumByRegion;
}

//calculate average
average = sum/count;


Then you can format your output with another set of loops:

for(int i=0; i &lt; regions; i++){
  System.out.printf("Region %d\t  Jan\t  Feb\t  Mar\t  Avg Rainfall%n", i+1);
  for(int j=0; j &lt; months; j++){
    System.out.printf("\t%2.1f",rainfall[i][j]);
  }
  System.out.printf("\t%2.1f%n", avgByRegion[i]);
}
System.out.println("The overall average rainfall is: " + average);