//Quiz: If the array a is 1 2 3 4 5 at the begining, i=1, j=3. what is the array at the end of main?
// A. 3 2 1 4 5
// B. 1 2 3 4 5
// C. 1 4 3 2 5

// This program swaps the elements in an array (posision i and j).
class SwapInArray
{
    public static void main (String[] args)
    {
        // DECLARE VARIABLES/DATA DICTIONARY 
        int [] a;  
        int i,j;  

        // READ IN GIVENS
        System.out.println( "Please enter the array:" );
        a = ITI1120.readIntLine( );
        System.out.println( "Please enter the index of the first element:" );
        i = ITI1120.readInt( );
        System.out.println( "Please enter the index of the second element:" );
        j = ITI1120.readInt( );
        swapInArray(a, i, j);
            
        // PRINT OUT RESULTS AND MODIFIEDS
        System.out.println( "The array is: ");
        for (int count = 0 ; count <a.length; count++)
          System.out.print(a[count] + " ");
    }

     public static void swapInArray ( int [] x, int i, int j)
     {  
       int temp;
       temp = x[i];
       x[i] = x[j];
       x[j] = temp;
     }     
} 
