Question
Example: 1. Fill array 2. Add a number 3. Find the index of a number 4. Remove number at index 5. Remove number 6. Quit
Example:
1. Fill array
2. Add a number
3. Find the index of a number
4. Remove number at index
5. Remove number
6. Quit 1
Enter your choice 1-6: 8
Please re-enter 1-6:2
42 1. Fill array
2. Add a number
3. Find the index of a number
4. Remove number at index
5. Remove number
6. Quit 1 Enter your choice 1-6: 2
42 54 1. Fill array
2. Add a number
3. Find the index of a number
4. Remove number at index
5. Remove number
6. Quit Enter your choice 1-6: 1
Enter number of elements 1-10:5
63 68 83 94 98
1. Fill array
2. Add a number
3. Find the index of a number
4. Remove number at index
5. Remove number
6. Quit Enter your choice 1-6:5
Enter number to remove: 99
99 is not found.
63 68 83 94 98
1. Fill array
2. Add a number
3. Find the index of a number
4. Remove number at index
5. Remove number
6. Quit
Enter your choice 1-6:5
Enter number to remove: 68
Use an int array of size 10. There should be no global variables at all, only constants are allowed. Use a variable to store the number of items the array contains (not all 10 elements will hold user data).
For each menu item 0-6, write a method that takes the array name, the number of items in addition to other arguments (eg: the size of the array) if/when needed.
- Fill array: Asks user how many numbers to fill (the length of the partially filled array). Validate the user entered number (1-10 inclusive). Fill the sorted array with random numbers 1-99 inclusive. The number of elements should be equal to the value specified by the user. Must use the provided insert Sorted method. You may not add a number then sort the array.
- Add a number: If array is full displays a message indicating that, otherwise add a random number in the correct position to the sorted array. You may not add a number then sort the array.
- Find index of a number: Displays the index of a number specified by the user f it exists otherwise a message saying that the number is not found.
- Remove number at index: Ask the user to enter the index. Remove the number at the specified index or display error message if the specified index is outside the current partially filled array size.
- Remove number: Ask the user to enter a number, remove it if it exists otherwise display a message to indicate that it does not exist. Must use the provided delete Element method.
For searching, you must use the provided binary Search method. The provided methods may not be modified.
Display the sorted array every time the menu is displayed.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started