Computer Programming

More Statistics

You are to modify your existing statistics program, so that the the user is able to find the mode, and median, of a list of entered numbers. When the list is displayed, all numbers must also be sorted in ascending order (from the smallest to the largest).

Do not assume that the user will enter the numbers in sorted order. Your program should take the list of numbers and sort it internally, before displaying it.

*Note*: User input is shown in ** bold
italic** text.

Statistics Program by John Doe Re Me This program allows you to enter a list of real numbers and perform various statistical calculations on them by selecting different options from a menu. Menu: a - add numbers to the list b - clear the list c - display the list d - display the number of items in the list (n) e - calculate the list's arithmetic mean (average, x-bar) f - calculate the list's standard deviation (s) g - calculate the list's variance (s-squared) h - calculate the list's range (xmax - xmin) i - calculate the list's median (x-tilde) j - calculate the list's mode k - exit Your choice:There are currently no numbers in the list. You may enter numbers, one per line. Enter 'end' (without quotation marks) when finished. You will then be taken back to the menu. #1:a#2:12.341 number was added to the list. Menu:end(Note: the menu body has been left out to save space)Your choice:There is currently 1 number in the list. You may enter more numbers, one per line. Enter 'end' (without quotation marks) when finished. You will then be taken back to the menu. #2:a#3:23.45#4:45.67#5:56.78#6:34.564 numbers were added to the list. Menu:end(Note: the menu body has been left out to save space)Your choice:Current contents of the list: 12.34, 23.45, 34.56, 45.67, 56.78c(Notice that the numbers are sorted from smallest to largest.)Menu:(Note: the menu body has been left out to save space)Your choice:Currently there is no mode. Menu:j(Note: the menu body has been left out to save space)Your choice:There are currently 5 numbers in the list. You may enter more numbers, one per line. Enter 'end' (without quotation marks) when finished. You will then be taken back to the menu. #6:a#7:23.451 number was added to the list. Menu:end(Note: the menu body has been left out to save space)Your choice:Current contents of the list: 12.34, 23.45, 23.45, 34.56, 45.67, 56.78c(Notice that the numbers are sorted from smallest to largest.)Menu:(Note: the menu body has been left out to save space)Your choice:Mode: mode = 23.45 Menu:j(Note: the menu body has been left out to save space)Your choice:Median: x-tilde = 29.01 Menu:i(Note: the menu body has been left out to save space)Your choice:There are currently 6 numbers in the list. You may enter more numbers, one per line. Enter 'end' (without quotation marks) when finished. You will then be taken back to the menu. #7:a#8:23.45#9:56.78#10:12.23#11:56.78#12:99.21end5 numbers were added to the list.Menu:(Note: the menu body has been left out to save space)Your choice:12.23, 12.34, 23.45, 23.45, 23.45, 34.56, 45.67, 56.78, 56.78, 56.78, 99.21c(Notice that the numbers are sorted from smallest to largest.)Menu: (Note: the menu body has been left out to save space)Your choice:Median: x-tilde = 34.56 Menu: (iNote: the menu body has been left out to save space)Your choice:Mode: modes = 23.45, 56.78 Your choice:jThank you for using this program. Goodbye!k

You will find Keith Calkins' Statistics Lessons particularly helpful. They contain explanations for the mode, and median. The terms and symbols involved in these calculations are also explained there.

As was stated in the previous assignment, each of the menu items should call a separate function. Write separate functions which handle the mode, median, and sorting of the list. Use one of the sorting algorithms discussed in class to sort your list of numbers into ascending order.

Remember to properly comment the program and each function, and to use good style and formatting practices.