Array Analyzer Objective: To gain practice with arrays and common array algorithms, as well as the use of arrays as para

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
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

Post by answerhappygod »

Array Analyzer Objective To Gain Practice With Arrays And Common Array Algorithms As Well As The Use Of Arrays As Para 1
Array Analyzer Objective To Gain Practice With Arrays And Common Array Algorithms As Well As The Use Of Arrays As Para 1 (105.93 KiB) Viewed 18 times
Array Analyzer Objective: To gain practice with arrays and common array algorithms, as well as the use of arrays as parameters to functions. Task Filename: arrays.cpp Write a program that begins by creating an array of size SIZE. Declare SIZE as a const int variable and set it to some value between 5 and 15. Since this is a constant variable, we can use it as the size of our array. We can change the value it stores from run to run for testing different size arrays. Use this constant variable in your code whenever referring to the array's max SIZE (instead of using a hard-coded literal value like 10 or 15). For our program, we can assume SIZE will be between 5 and 15, so use values within this range when testing your code. const int SIZE = 5; //Used as the size of our array int list[SIZE]; // creation of an array of size SIZE Once you've created your integer array of size SIZE, you're ready to begin your program. You can use my example array creation above, or make an array named whatever you'd like instead. RULE: NO OTHER ARRAYS should be created in your program besides this original array. Start off by asking the user if they want to fill up the array manually or if they want to fill the array randomly. The user should enter c for custom fill, or r for random fill. FORCE a correct entry of either r or c here before you proceed. If the user chooses c, allow the user to initialize the array with data they enter via the keyboard (cin). Make sure to tell the user how many values they should enter. If the user selects r, fill up the array with random integer values in the range of 1 to 100. When the user enters values, you may assume that the user will always enter the appropriate number of values, and that these values will be integers. Keep in mind that the user CAN enter negative values into the array if they choose.
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.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply