|
-
May 17th, 2013, 08:49 PM
#1
Thread Starter
New Member
Need Some Array Help
I dont know if anyone can really help me with this but I'm kind of stuck in a bind. I need to create a program that loads a text file filled with numbers and creates an array out of it and then lists it in listbox1 when you press the first button. When you press the 2nd button, it needs to sort the array in ascending order and list it in listbox2. While sorting, there needs to be a line of output each in listbox3 stating the number of elements in the array, the max and min value, the sum of all values, the mean of the values, the median of the values, and the mode of the values. I literally do not have a clue where to start with this and was hoping maybe someone here might. Thank you to anyone that can help and if not, thank you for atleast reading this.
-
May 17th, 2013, 10:05 PM
#2
Re: Need Some Array Help
Hi,
This feels like an assignment so just break this down into logical steps and have a look at these. i.e:-
1) Read The File into an Array.
http://msdn.microsoft.com/en-us/libr...code-snippet-1
2) Add the Array to a ListBox.
http://msdn.microsoft.com/en-us/library/z018s5az.aspx
3) Sort The Array and Add to New ListBox
http://msdn.microsoft.com/en-us/library/kwx6zbd4.aspx
4) To get the Min, Max, Average and Sum of an Array, have a look at the Functions available to a Declared Array of Integers
5) To get the Median number, you can use the Index of the Array to get the middle number in the Sorted Array if the number of items in the array is ODD. If EVEN then you need to get the TWO middle numbers using their Index in the Array and do the correct Math.
6) Since I do not know what you have been taught so far, to get the Mode I would suggest that you are going to have to use a For Loop of some kind to iterate through the array and count the number of occurrences of each number. The number with the most occurrences is then the mode.
http://msdn.microsoft.com/en-us/libr.../5ebk1751.aspx
Hope that helps.
Cheers,
Ian
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|