Two-dimensional Arrays

Sometimes we want to use a "two-dimensional" table in our program:

 

           Low/High  Temperatures
		    
       Sun  Mon  Tue  Wed  Thu  Fri  Sat


Low     35   35   45   49   53   53   55

High    50   52   68   75   78   76   75



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


   

    //Ouput low temperature for Sunday
    
    
 
    
    //Output high temperature for Thursday
    

    
    
    //Output low temperature for Tuesday
    


    
    
       Sun  Mon  Tue  Wed  Thu  Fri  Sat


Low     35   35   45   49   53   53   55

High    50   52   68   75   78   76   75

   //Calculate the average low temperature
    







    
    
    //Calculate the average temperature overall
    
 
 
 
 
 
 
 
    
    
    //Determine the temperature range
    
 
 
 
 
 
 
 
    
    
  }
}

Using a 2D array to store an "addition table":

 
  0  1  2  3  4  5

  1  2  3  4  5  6

  2  3  4  5  6  7

  3  4  5  6  7  8

  4  5  6  7  8  9
 
  5  6  7  8  9 10

public class AdditionTable {
  public static void main(String[] args) {
    //Create the table
 
 
 
 
 
 

 
 
 
 
 
	
    //Print it out

    
    
    

    
    
    
    
    
    
  }
}