public class Rand
{
	public static void main(String[] args)
	{
		// Initilize Variables //
		int bigID = 0;   //The array
		int big = 0;     //The number
		int sum = 0;	 //The sum of all
		int[] a = {10, 15, 6, 14, 75, -15, 29, 28};
		int temp;
		final int lastNum = (a.length -1);

		// Display the length of a //
		System.out.println("The length is: " + a.length);
		System.out.println("\n");

		// Calculate sum and output the array //
		for(int j=0; j < a.length; j++)
		 {
		 sum += a[j];
		 System.out.println("Number " + j + " is :" + a[j]);
		 }
		System.out.println("\n");

		//Display the sum //
		System.out.println("The sum is: " + sum);

		//Calculate the big number and it's position in the array //
		for(int j=0; j < a.length; j++)
		  {
			if(a[j] > big)
			 {
		   	  big = a[j];
		   	  bigID = j;
	 		 }
		  }

		//Print out the number, and show user the change //
		System.out.println("\n");
		System.out.println("The biggest number is: " + big + " at sub: " + bigID);
		System.out.println("Now we will take " + bigID + " and move it to " + (a.length - 1));
		System.out.println("\n");

		// Relplaces the numbers accordingly //
			temp = a[lastNum];
			a[lastNum] = big;
			a[bigID] = temp;

		// Show the user what has changed //
		for(int j=0; j < a.length; j++)
		{
		 System.out.println("Number " + j + " is now :" + a[j]);
		}

		System.out.println("\n");
		System.out.println("Numbers " + big + " and " + temp + " were switched.");

		//Now order it according to size://
		System.out.println("\nNow we will reorder the array:");
		int q;
			for (int k=lastNum; k>1; k--)
		  	{
				for(int j=0; j < a.length-1; j++)
				{
						System.out.println(a[j]+ " VS "+ a[k]);
						if(a[j] < a[k])
						{
							System.out.println(a[k] + " wins it moves up");
							swap(a[], a[k], a[j]);
						}
							else
							{
								System.out.println(a[j] + " wins it moves up");
								swap(a[], a[j], a[k]);
							}
				}
			}



		// Show the user what has changed //
		 		for(int j=0; j < a.length; j++)
		 		{
		 		 System.out.println("Number " + j + " is now :" + a[j]);
		}

	}

public static void swap(int a[],int x, int y)
{
	int temp2 = a[x];
	a[x] = a[y];
	a[y] = temp2;

}
}
