Array Analyzer Objective: To gain practice with arrays and common array algorithms, as well as the use of arrays as para
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Array Analyzer Objective: To gain practice with arrays and common array algorithms, as well as the use of arrays as para
Now that the array is filled up with data, display the following: • The array's contents, separated by commas (with NO trailing comma after the last value) . The minimum number in the array . The maximum number in the array • The sum of the numbers in the array • The average of the numbers in the array (printed to 1 decimal place precision) The array's contents, sorted from least to greatest, separated by commas (with NO trailing comma after the last value) • The median of the array (printed to 1 decimal place precision) • The highest frequency count (The number of times that the most frequent value in the list appears) • OPTIONAL EXTRA CREDIT (5 points): If the highest frequency count is more than zero, print out all of the values that appear at the highest frequency Function requirements: You're required to utilize at least 3 functions in addition to main() in your program that serve a valid purpose towards the goal of this program. The functions you choose to create and their uses will be a graded portion of this assignment. (20 points). Your functions can be named whatever you choose. Your functions can return whatever you choose. Your functions can take in as parameters whatever you choose. Functions that take in the array as a parameter but do not change the contents of the array should take in the array as "const". Functions that are clearly present in a student's code "just to serve the purpose of fulfilling this requirement" will not earn points.
To keep in mind: Remember that in this assignment we are working with an INTEGER array. This means that the c-string ideas we will learn are not available to us here as this is not a character array. It may help you to sort the array's contents before working on finding the median and the highest frequency. It is helpful to remember that the first array element is index 0, and the last array element is index SIZE - 1. Bonus Point Opportunities: • EXTRA CREDIT (5 points): If the highest frequency count is more than zero, print out all of the values that appear at the highest frequency General Requirements • ***No global variables*** • You're not permitted to create any additional arrays in your code besides the original one in main(). • You will need the iostream, iomanip, ctime, and cstdlib libraries. No other libraries are permitted. • As always, your source code must be readable and appropriately commented/documented • Code from the course notes or the e-text can be used, but please cite the source in a comment near the section of code. Sample Runs The highlighted output in the sample runs below illustrates the extra credit option.
When SIZE = 15 Enter (c)ustom or (r)andom values? --> r Array analysis: Your array: 63,79,81,100,44,28,33,81,35,9,96,51,99,15,9 Minimum: 9 Maximum: 100 Sum: 823 Mean: 54.9 Sorted array: 9,9,15,28,33,35,44,51,63,79,81,81,96, 99, 100 Median: 51.0 Highest Frequency Count: 2 Value(s) that appear 2 times: 9 81 When SIZE = 10 Enter (c)ustom or (r)andom values? --> R Enter (c)ustom or (r)andom values? --> x Enter (c)ustom or (r)andom values? --> < Enter 10 numbers: 30 29 83 72 91 -89 -2 0 55 1 Array analysis: Your array: 30,29,83,72,91, -89, -2,0,55,1 Minimum: -89 Maximum: 91 Sum: 270 Mean: 27.0 Sorted array: -89,-2,0,1, 29, 30, 55,72,83,91 Median: 29.5 Highest Frequency Count: 1
Enter (c)ustom or (r)andom values? --> < Enter 10 numbers: 1 1 1 1 1 1 1 1 1 1 Array analysis: Your array: 1,1,1,1,1,1,1,1 Minimum: 1 Maximum: 1 Sum: 10 Mean: 1.0 Sorted array: 1,1,1,1,1 Median: 1.0 Highest Frequency Count: 10 Value(s) that appear 10 times: 1 When SIZE=7 1,1,1 Enter (c)ustom or (r)andom values? --> < Enter 7 numbers: 3 3 4 4 9 9 0 Array analysis: Your array: 3,3,4,4,9,9,0 Minimum: 0 Maximum: 9 Sum: 32 Mean: 4.6 Sorted array: 0,3,3,4,4,9,9 Median: 4.0 Highest Frequency Count: 2 Value(s) that appear 2 times: 3 4 9 This should give you an idea of how your program should behave. So long as your output format is clean, I don't mind if your output deviates a bit from the look of mine. You can use different wording as well if you choose.