MSCCS200
Computer Programming
More Statistics

Description

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

Details

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.

Sample Run

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: a

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: 12.34
#2: end

1 number was added to the list.

Menu:
	(Note: the menu body has been left out to save space)
Your choice: a

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: 23.45
#3: 45.67
#4: 56.78
#5: 34.56
#6: end

4 numbers were added to the list.

Menu:
	(Note: the menu body has been left out to save space)
Your choice: c

Current contents of the list:
     12.34, 23.45, 34.56, 45.67, 56.78 
	(Notice that the numbers are sorted from smallest to largest.)

Menu:
	(Note: the menu body has been left out to save space)
Your choice: j

Currently there is no mode.

Menu:
	(Note: the menu body has been left out to save space)
Your choice: a
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: 23.45
#7: end

1 number was added to the list.

Menu:
	(Note: the menu body has been left out to save space)
Your choice: c

Current contents of the list:
     12.34, 23.45, 23.45, 34.56, 45.67, 56.78 
	(Notice that the numbers are sorted from smallest to largest.)

Menu:
	(Note: the menu body has been left out to save space)
Your choice: j

Mode:
	mode = 23.45

Menu:
	(Note: the menu body has been left out to save space)
Your choice: i

Median:
	x-tilde = 29.01

Menu:
	(Note: the menu body has been left out to save space)
Your choice: a
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: 23.45
#8: 56.78
#9: 12.23
#10: 56.78
#11: 99.21
#12: end

5 numbers were added to the list.

Menu:
	(Note: the menu body has been left out to save space)
Your choice: c
     12.23, 12.34, 23.45, 23.45, 23.45, 34.56, 45.67, 56.78, 56.78, 56.78, 99.21
	(Notice that the numbers are sorted from smallest to largest.)

Menu:
	(Note: the menu body has been left out to save space)
Your choice: i

Median:
	x-tilde = 34.56

Menu:
	(Note: the menu body has been left out to save space)
Your choice: j

Mode:
	modes = 23.45, 56.78
Your choice: k

Thank you for using this program.  Goodbye! 

Implementation

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.