Reversing an Array

Write a program, ReverseIt, that prompts the user for an integer, then asks the user to enter that many integers. Store these values in an array. Write a method, printArray, that takes an array of integers as its only parameter and print the contents of the array in the format: "{x1, x2, x3, ... xn}", including the curly-brackets and the commas. (It can be tricky to get the commas only between the elements--take care.) Your program should call printArray to print the values entered by the user. Test your program now.

Modify your program so that after it prints the original array it reverses the array elements so that the first element becomes the last element, the second element becomes the second to last element, and so on, with the old last element now first. Do not just reverse the order in which they are printed; actually change the way they are stored in the array. Do not create a second array; just rearrange the elements within the array you have. (Hint: accomplish the reversal with a loop, each of whose iterations swaps two elements of the array (for example, the first and last). Remember that to swap two values you need three variables--in your case two of the "variables" are array elements, while the third will just be a local variable.) When the elements have been reversed, use printArray to print the array again.

Submit your ReverseIt.java, to the dropbox, along with a transcript of your program executing twice, first on a 5 element array, then on a 6 element array.