Homework : Due December 9th

 

Read chapter 7, section 7.9

  1. What is a two-dimensional array?
  2. How many subscripts do you need to access an element of a two-dimensional array?
  3. Read about initializing a two-dimensional array.
  4. Given:
            int [][] array = { {1,2,3}, {4,5,6} };
    
    1. How many rows does the array have?
    2. How many columns does the array have?
    3. Give the name of the field that represents the number of rows?
    4. Give the name of the field that represents the number of columns in the row with subscript 0.
  5. Write the code (calling statement) to pass the array in question 4 to a method called sumArray that will return the sum of the array passed.
  6. Write method sumArray.
  7. Complete Multiple Choice and True/False: questions 10 and 21
  8. Complete Algorithm Workbench: 6-10
  9. Complete Short Answer 9.
  10. Given: int[][] values = new int[4][5]. Write a nested loop to set values as follows:
    	         [0] [1] [2] [3] [4]
    	      [0] 1   2   3   4   5
    	      [1] 1   2   3   4   5
    	      [2] 1   2   3   4   5
    	      [3] 1   2   3   4   5
    	
  11. Given: int[][] values = new int[4][5]. Write a nested loop to set values as follows:
    	         [0] [1] [2] [3] [4]
    	      [0] 0   1   2   3   4
    	      [1] 1   2   3   4   5
    	      [2] 2   3   4   5   6
    	      [3] 3   4   5   6   7
    	
  12. Given: int[][] matrix = new int[5][5]. Write a nested loop to set matrix as follows:
    	         [0] [1] [2] [3] [4]
    	      [0] 1   0   0   0   0
    	      [1] 0   1   0   0   0
    	      [2] 0   0   1   0   0
    	      [3] 0   0   0   1   0
    	      [4] 0   0   0   0   1
    	

Email Me | Office Hours | My Home Page | Department Home | MCC Home Page

© Copyright Emmi Schatz 2013