// Program Name:         Array2DClient.java
// Course:               CSE 1302J
// Student Name:         Bradley Shedd
// Assignment Number:    Lab 3
// Due Date:             09/15/2010
// Purpose:              This creates a program that will read in two values, row and col, and create an array of that size.
//                              

   import java.io.*;
  
import java.util.Scanner;
//
    public class Array2DClient
   {
      
public static void main (String[] args) throws IOException
      {
     
//reads in two values and creates an array
         Scanner scan = new Scanner (new File("input.txt"));
       
int row, col;
         row = scan.nextInt();
         col = scan.nextInt();
        
int [] [] A = new int [row] [col];
     
//Clears arrays to zeros
         for (int i = 0; i < row; i++)
           
for (int j = 0; j < col; j++)
               A[i] [j] = 0;
     
//Reads in next     
         row = scan.nextInt();
         col = scan.nextInt();
        
int value = scan.nextInt();
     
//Reads for sentinel
         while (row != -1)
         {
            A[row] [col] = value;
            row = scan.nextInt();
            col = scan.nextInt();
            value = scan.nextInt();
         }
        
for (int i = 0; i< A.length; i++)
         {
           
for (int j = 0; j< A[i].length; j++)
               System.out.print(A[i][j]+
"\t");
            System.out.println();
         }
         System.out.println(
"Coded by: Bradley J. Shedd");
      }
   }
     
      The text file needs to be saved in the same location as the code. The layout needs to be the same below.

6
4
0 0 45
1 1 9
2 2 569
3 2 17
2 3 -17
5 3 9999
-1 -1 -1


Homepage