Java programming: Please write comments so that I can understand and code it whe
ID: 3717616 • Letter: J
Question
Java programming:
Please write comments so that I can understand and code it where it is simple enough for a beginner to understand.
Write a method, remove, that takes three parameters: an array of integers, the length of the array, and an integer called removeItem. The method should find and delete the first occurrence of removeItem in the array. If the value does not exist or the array is empty, output an appropriate message. (Note that after deleting the element, the array size is reduced by 1.) You may assume that the array is unsorted.
Now re-do this exercise and name it ExInsertionSort. This time use an insertion sort as given in this chapter to sort the array and then remove the item with the array sorted. Create a method for the insertion sort. Please only provide the code for ExInsertionSort.
Explanation / Answer
Please find my implementation.
Output:
Enter value to remove: 54
Array before deletion:
10 20 40 50 70 89
Element not found
Array after deletion:
10 20 40 50 70 89
Process finished with exit code 0
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.