Question: Write a program that displays the following menu: 0. Create array 1. Find high, low, sum average 2. Add a number to the end 3.

Write a program that displays the following menu:

0. Create array 1. Find high, low, sum average 2. Add a number to the end 3. Find the index of a number 4. Insert number at index 5. Remove number at index 6. Remove number 7. Quit

Functionality We suggest that you develop your program incrementally. Meaning one menu item at a time. If it works correctly, add another one and so on.

Create an array of integers with size 100. Use a variable to store the number of filled elements (not all 100 elements will hold user data).

0. Create array: Asks user how many numbers to fill (the length of the partially filled array), with random numbers 0-9. Validate the user entered number (1-99). Fill the array with random numbers 0-9. The number of elements should be equal to the value specified by the user.

1. Calculates and prints the highest value, lowest, sum, and average of the partially filled array.

2. Add a number to the end: asks user to enter a number and adds it to the end of the partially filled array.

3. Find index of a number: Displays the index of a number if it exists otherwise a message saying that the number is not found.

4. Insert number at index: Ask the user to enter a number and the index to insert it in. Display error message if the specified index is outside the current partially filled array size.

5. 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.

6 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. .

Example: 0. Create array 1. Find high, low, sum average 2. Add a number to the end 3. Find the index of a number 4. Insert number at index 5. Remove number 6. Remove number at index 7. Quit 0

Page 1 of 5

CISC 1600/1610

Prof. Kadri

Enter the length of the array: 5 12 24 45 67 78

0. Create array 1. Find high, low, sum average 2. Add a number to the end 3. Find the index of a number 4. Insert number at index 5. Remove number 6. Remove number at index 7. Quit 2 Enter a number to add: 3 12,24,45,67,78,3

0. Create array 1. Find high, low, sum average 2. Add a number to the end 3. Find the index of a number 4. Insert number at index 5. Remove number 6. Remove number at index 7. Quit 3 Enter the number to find: 14 14 does not exist 12,24,45,67,78,3

0. Create array 1. Find high, low, sum average 2. Add a number to the end 3. Find the index of a number 4. Insert number at index 5. Remove number 6. Remove number at index 7. Quit 3 Enter the number to find: 67 67 is at index 3 12,24,45,67,78,3

0. Create array 1. Find high, low, sum average 2. Add a number to the end 3. Find the index of a number 4. Insert number at index 5. Remove number 6. Remove number at index 7. Quit 4

Page 2 of 5

CISC 1600/1610

Prof. Kadri

Enter the number to insert: 10 Enter the index to insert: 1 12,10,24,45,67,78,3

0. Create array 1. Find high, low, sum average 2. Add a number to the end 3. Find the index of a number 4. Insert number at index 5. Remove number 6. Remove number at index 7. Quit 4 Enter the number to insert: 10 Enter the index to insert: 10 The specified index is outside the array

12,10,24,45,67,78,3

0. Create array 1. Find high, low, sum average 2. Add a number to the end 3. Find the index of a number 4. Insert number at index 5. Remove number 6. Remove number at index 7. Quit 5 Enter the number to remove: 16 16 does not exist

12,10,24,45,67,78,3

0. Create array 1. Find high, low, sum average 2. Add a number to the end 3. Find the index of a number 4. Insert number at index 5. Remove number 6. Remove number at index 7. Quit 5 Enter the number to remove: 78

12,10,24,45,67,3

0. Create array 1. Find high, low, sum average 2. Add a number to the end 3. Find the index of a number 4. Insert number at index 5. Remove number 6. Remove number at index 7. Quit

Page 3 of 5

CISC 1600/1610

Prof. Kadri

6 Enter the index to remove:12 12 is outside the array

12,10,24,45,67,3

0. Create array 1. Find high, low, sum average 2. Add a number to the end 3. Find the index of a number 4. Insert number at index 5. Remove number 6. Remove number at index 7. Quit 5 Enter the index to remove:2

12,10,45,67,3

0. Create array 1. Find high, low, sum average 2. Add a number to the end 3. Find the index of a number 4. Insert number at index 5. Remove number 6. Remove number at index 7. Quit 0 Enter the length of the array: 3

21,33,97

0. Create array 1. Find high, low, sum average 2. Add a number to the end 3. Find the index of a number 4. Insert number at index 5. Remove number 6. Remove number at index 7. Quit 7 Goodby.

Challenge:

Add menu items to: Plot histogram

For the last item on the Challenge array, define a function histogram() that takes a array of integers and prints a histogram to the screen. For example, histogram(14, 9, 7,23) should print the following:

$**** *********

Page 4 of 5

CISC 1600/1610

Prof. Kadri

******* $$***

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!