Question: Please write a C++ program that will accept a list of integers (up to 20) from the user into a list , and then show

Please write a C++ program that will accept a list of integers (up to 20) from the user into a list, and then show those numbers in ascending order (after being sorted by your sort function), the sum of all integers, and their average. Then, your program allows the user to search for a number in the list. If the number (from the user) is in the list, please show its index position in the list, otherwise please say the number is not found. To make your program really user-friendly, the index position should start from 1, not 0. Please stop the search game if the user enters -99 as a number to search. Then, you continue to accept another list of integers (up to 20) from the user. Please stop your program with a thank-you message if the user enters zero as the number of integers to play. Please see the sample test below to design your application program properly. This program is like a game of sorting and searching for users to play.

You must write your sort function to sort the integers in the list. You may use any sorting technique to sort the numbers. You must write your search function to search for the number requested by the user. Please use binary search instead of sequential search technique because the list has been sorted already by your sorting function. You may reference the textbook for some sorting and searching algorithms. You must not call/use the existing sort( ) method for list in your program.

The following is a sample test,

Welcome to the List Sorting and Searching program designed by "your name"

Please enter how many integers you would like to play (up to 20, 0 to stop) > 5

Please enter number> 2

Please enter number> 5

Please enter number> 3

Please enter number> 4

Please enter number> 1

Your 5 integers in ascending order are: 1 2 3 4 5

The sum of all integers is 15, and their average is 3

Please enter a number to search (-99 to end the search)> 4

The number 4 is found at the position 4

Please enter a number to search (-99 to end the search)> 44

The number 44 is not found.

Please enter a number to search (-99 to end the search)> 1

The number 1 is found at the position 1

Please enter a number to search (-99 to end the search)> -99

Please enter how many integers you would like to play (up to 20, 0 to stop) > 6

Please enter number> 9

Please enter number> 20

Please enter number> 5

Please enter number> 3

Please enter number> 34

Please enter number> 18

Your 6 integers in ascending order are: 3 5 9 18 20 34

The sum of all integers is 89, and their average is 14

Please enter a number to search (-99 to end the search)> 34

The number 34 is found at the position 6

Please enter a number to search (-99 to end the search)> 19

The number 19 is not found.

Please enter a number to search (-99 to end the search)> 3

The number 3 is found at the position 1

Please enter a number to search (-99 to end the search)> 20

The number 20 is found at the position 5

Please enter a number to search (-99 to end the search)> -99

Please enter how many integers you would like to play (up to 20, 0 to stop) > -99

Please enter how many integers you would like to play (up to 20, 0 to stop) > -4

Please enter how many integers you would like to play (up to 20, 0 to stop) > 0

Thank you for using program by "your name"

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!