Movie Data Write a program that will be used to gather statistical data about the number of movies college students see in a month. The program should ask the user how many students were surveyed and dynamically allocate an array of that size. The program then should allow the user to enter the number of movies each student has seen. It should then sort the scores and calculate the average.
Movie Data
Write a program that will be used to gather statistical data about the number of movies college students see in a month. The program should ask the user how many students were surveyed and dynamically allocate an array of that size. The program then should allow the user to enter the number of movies each student has seen. It should then sort the scores and calculate the average.
Modularity:
Main: The main function should accept the number of students from the user and dynamically create an array large enough to contain number of movies watched for each student. Input validation: The number of students should be a positive integer. Print the average and free the allocated array when complete.
Get the data: This function should get the number of movies watched by each college student. Input validation: The number of movies should be a positive integer.
Sort the data: This function should sort the array in ascending order. Note you may use the Standard Template Library sort function or your own sort function. To use the STL sort:
Add #include <algorithm> to your program
sort (arrayname, arrayname + size of array) (beginning and ending elements)
Display: This function should display the sorted list of the number of movies watched.
Average: This function should be a value-returning function that calculates the average of the movies watched and returns it to the main function.
Sample Output:
Number of Movies Watched
------------------------
75
81
88
---------
Average 81.3
Requirements: Your array must be dynamically allocated. In passing your array to functions, you must declare the array parameter using pointer notation instead of array notation, and inside each function you must use pointer notation instead of array notation to access the array elements.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
does not give the display function that displays the sample output