Question: AP 9 (Array Stats) Submit Assignment Due Jan 28 by 10:59pm Points 5 Submitting a text entry box Available Jan 24 at 11pm - Jan

 AP 9 ("Array Stats") Submit Assignment Due Jan 28 by 10:59pm

AP 9 ("Array Stats") Submit Assignment Due Jan 28 by 10:59pm Points 5 Submitting a text entry box Available Jan 24 at 11pm - Jan 31 at 10:59pm 7 days Given an array of integers, how can we make some basic statistical calculations on the data? Specifically, we want to be able to determine the mean, median, and mode of the array of integers. You will hopefully recall what each of these terms mean (oops, that was so punny!). Mean is the arithmetic average of a series of numbers. It is found by summing all of the numbers and then dividing by the number of elements (numbers) in the series. Median is the middle number (of a sorted set). Given a sorted array, it is found by finding the number that is in the middle of the array. Mode is the number that appears the most frequently. Given a sorted array, all of the repeated numbers will be consecutive (in other words, repeated numbers are next to each other). To find the mode you must keep track of which number is repeated the most (has the highest frequency). To get started on this assignment, download, extract, and save the ArrayStatsTest to your computer. You will notice that there is only class, namely Arraystatstest. You can run the Arraystatstest class anytime you like to see how much of the assignment you have completed. Now go ahead and create a new Arraystats class in your Array Stats project. Your assignment is to write an arraystats class with the following three methods: public static double findMean(int[] a) public static int findMedian(int[] a) public static int findMode(int[] a) Each method will utilize an integer array as a passed parameter. The passed array may be of any length, but you may assume that it is already sorted in ascending order. Each method will then perform the appropriate calculation and return the proper result. 1. Start by writing the method findMean . You will need to iterate through the entire array, adding up all of the values, and then divide the total by the total number of elements in the array. The result is returned as a double because it will probably be a value with a remainder (decimals). 2. Next, write the method findMedian. Again, you may assume the array is already sorted for you, so you just need to pick the middle element. Note that it does not matter if there are an odd number or an even number of elements in the array. Just take the length of the array and divide by two to find the index for the middle element. Here is another example where integer division works to our advantage (we'll always get an integer index when dividing the array length by 2). 3. Finally, write the method findMode. This will probably be the most difficult to do. You must keep track of the number of times a given number is repeated in other words, find its frequency). Note that you are not being asked for the frequency of all the numbers, just the one that is the highest (repeated the most). Think about how you can do this. Remember that the array is already sorted in ascending order, so numbers that appear more than once are right next to each other. You probably want to keep track of the number of times a given element is the same value as the one either before or after it. Be careful here, however, as you now are looking at two values of an array at the same time, so it is easy to generate range-bound errors (subscripts out-of-bounds) when you run the program. Writing a simple but effective algorithm to count these values is a challenging task, but it can be done. (Here is a hint , if you need one.) Good luck. Show me the results of your successful test when you are finished. Feel free to see me if you have any questions or difficulties in the meantime

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!