Question
// Please use c++ for visual studio. Write a program that uses statistical data about the number of movies college students see in a month.
// Please use c++ for visual studio.
Write a program that uses statistical data about the number of movies college students see in a month. The program should perform the following steps:
a) Open an input file and read the number of students surveyed. An array of integers with this many elements should then be dynamically allocated
b) Read the statistics that list number of movies each student watched in a month.
c) Calculate and display the average, median, and mode of the values entered. (a description of each is below. Note: You will have to sort the values) - a function should be written for the average, median, and mode.
Input validation: do not accept negative numbers for input Output should go to a file
. The file should look like the following:
"Statistics for Movie Viewing of College Students" February 2018 Total Students Surveyed:
Average: x.x Median: y.y Mode: z.z Where x, y, z are the actual values for Average, median, and mode
The Average is the sum of the values divided by the number of values
The Median is the middle value of a list of values after they are sorted.
If the set contains and even number of elements, the median is the average of the two middle values The Mode is the value that occurs the most (with greatest frequency) in a list of values
this is the content of the file:
Number of students surveyed 40
Number of movies students watched in a month follow
8 4 4 4 4 3 2 0 1 2 3 1 5 7 12 5 7 4 3 6 1 8 6 4 5 3 1 1 5 2 6 3 3 6 3 9 2 0 8 5
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started