|
|
How many student are surveyed? 5 Write by order, the number of movies watched by each of the students Student#1: 10 Student#2: 8 Student#3: 10 Student#4: 12 Student#5: 12 The total of movies watched by all the students is:1095516538movie. The Average of movies watched is:2.19103e+008movie. The median of movies watched is:5.47758e+008movies. -------------------------------- Process exited with return value 0 Press any key to continue . . . |
Write a program that can be used to gather statistical data about the number of movies college students see in a month. The program should perform the following steps: 1. Ask the user how many students were surveyed. Dynamically allocate an array with this number of elements. 2. Allow the user to enter the number of movies each student saw into the array. The question for the entry should read : "How many movies did student X see?" where you substitute the number of the student for X. Remember that your array index will start at zero but that you should be asking for student 1, student 2, etc. Do not allow negative numbers to be entered. 3. Write functions to do the following: 1. Sort the array from lowest to highest number of movies viewed. 2. Calculate the average number of movies viewed by the students. The average is the sum of all of the movies viewed divided by the number of students. Display the average number of movies viewed by the students. 3. Determine the median number of movies for all the students. The median is is the middle value of the array, For example, if 5 students were entered, the number of movies viewed by student 3 is the median value. If an even number of students is entered, the median is the average of the 2 values in the middle. Display the median value of the array. 4. Compute the mode of the array. The mode is the number of movies viewed most frequently. For example, in an array of 5 students who viewed 5, 3, 8, 5, and 2 movies, 5 will be the mode because 2 students viewed that number of movies. If the array has no mode (all of the numbers are different), display a message indicating that there is no mode. 4. The array should be passed to each of the functions as a pointer to the array. |
total += studentnum[count];
|
|
|
|
How many student are surveyed? 10 Write by order, the number of movies watched by each of the students Student#1: 10 Student#2: 12 Student#3: 10 Student#4: 9 Student#5: 8 Student#6: 3 Student#7: 6 Student#8: 10 Student#9: 13 Student#10: 20 The total of movies watched by all the students is:156movie. The Average of movies watched is:15movie. The median of movies watched is:78movies. -------------------------------- Process exited with return value 0 Press any key to continue . . . |
average = total/students_surveyed;
, the program does this:median = total / 2.0.