Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Rob, Carlos Coronel

3rd Edition

0760049041, 978-0760049044

More Books

Students also viewed these Databases questions

Question

Shift of HR policy-making from local to central level.

Answered: 1 week ago