If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Threaded View

Can anybody crack this..........?

Write, compile, and run a program to do the following. Add comments to each class and each method in the standard form (javadoc-compatible). Remember to define all variables at the beginning of each method. Submit the source files as a Reply to this posting.

1. Write a static method displayArrayAsTable which takes three parameters: an array of integers, the number of elements in the array, and the number of integers to be displayed per line. The method should display the elements of the array in a table of the given number of integers per line (the last line may have to be shorter).

2. In the main method:
• Prompt the user for the number of integer values to sort.
• Create an array of the entered size.
• Randomly generate the given number of integers and store the integers in the array.
• Display the array of integers in a table of 10 integers per line using displayArrayAsTable.
• Copy the array into another array. Sort the second array using selection sort. Display the name of the sort and its running time. Display the sorted array in a table of 8 integers per line using displayArrayAsTable.
• Copy the array into yet another array using insertion sort. Display the name of the sort and its running time. Display the sorted array in a table of 7 integers per line using displayArrayAsTable.
• Copy the array into yet another array. Sort the second array using bubble sort. Display the name of the sort and its running time. Display the sorted array in a table of 9 integers per line using displayArrayAsTable.