Solution:
#include<iostream>
//Including header files..
#include<string>
using namespace std;
double median(int *, int);
//Declaring functions..
int mode(int *, int);
double average(int *, int);
int getInput();
int main() {
int END = 1;
//Conditional variable..
int studentsCount; //To store no.of
students were surveyed
int studentsWatched[100];//To store no.of movies
each student saw..
int i = 0;
double med;
//Declaring variables..
double mod;
double avg;
while (END) { //Loop to get valid input..
cout <<"\n How many
students were surveyed? ";
studentsCount =
getInput(); //Function call to read
input..
if (studentsCount != -1) {
cout <<"\n
Enter the number of movies each student saw.\n";
for (i = 1; i
<= studentsCount; i++) //Index start at '1'..
{
cout <<" Student
"<<i<<": ";
studentsWatched[i]= getInput(); //Function call
to read input.
if (studentsWatched[i] == -1)
//Invalid input..
{
i--; //Repeat prompting the value from uesr..
cout<<"
The number of movies must be greater than zero.";
cout <<"\n
How many movies were seen by";
}
}
med =
median(studentsWatched, studentsCount); //Func call to
find median..
mod =
mode(studentsWatched,studentsCount);
//Func call to find mode..
avg =
average(studentsWatched, studentsCount);
//Func call to find average..
//Printing
output...
cout<<"
The average number of movies seen is "<<avg;
cout<<".\n
The median of the number of movies seen is "<<med;
cout<<".\n
The mode of the number of movies seen is
"<<mod<<".\n"<<endl;
END =
0; //Exit program..
}
else
cout<<" The number of students must be greater than
zero.";
continue;
//Start from first..
}
return 0;
}
/*
* Function to find the median..
*/
double median(int *studentsWatched, int studentsCount)
{
int middle = (studentsCount/2)+1;
double median = 0;
if (studentsCount % 2 == 1)
median = *(studentsWatched +
middle);
else
median =
(double)((*(studentsWatched + middle-1) + *(studentsWatched +
middle)) / 2);
return (double)median;
}
/*
* Function to find the mode..
*/
int mode(int *studentsWatched, int studentsCount)
{
int mod = *(studentsWatched + 1); //Assigning first
element..
int result = mod;
//To store the
result..
int count = 1;
//To store
the count..
int modCount = 1;
//To store the modCount..
for (int i = 2; i <= studentsCount+1; i++)
{
if (*(studentsWatched + i) == mod)
{
count++; //Increase count
value..
}
else {
if (count >
modCount)
{
modCount = count; //Storing the highest
count
result = mod; //Storing
the highest count's index
}
count = 1;
// Reset the value of count next
nos..
mod =
*(studentsWatched + i); //Assigning next element..
}
}
return result;
}
/*
* Function to find the average..
*/
double average(int *studentsWatched, int studentsCount)
{
int sum = 0; //To store
the sum of array elements..
for (int i = 1; i <= studentsCount; i++)
sum +=
*(studentsWatched + i); //Calculating sum
return (double)sum/studentsCount;
//Calculating average & return..
}
/*To read the input from the user..*/
int getInput()
{
int input;
cin>> input;
if(input > 0)
return input; //Return
if valid input..
else
return -1;
//If invalid input..
}
---------------------------------------------------------------------------
Code Screenshots:




-------------------------------------------------------------------------
Output:

--------------------------------------------------------
Please comment if you have any queries or changes required in this solution..
Kindly up-vote if you are satisfied with this solution..
C++ : Proj... Make sure to have at least this three functions: double median(int *, int);...
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: A) Ask the user how many students were surveyed. An array of integers with this many elements should then be dynamically allocated. B) Allow the user to enter the number of movies each student saw into the array. C) Calculate and display the average, median, and mode of the values entered....
THE CODE CALCULATES THE MEAN MEDIAN AND MODE OF THE SET OF NUMBERS THE CODE IS WRITTEN IN C++ PLEASE FIX THE MODE FUNCTION ! SO THAT IT OUTPUTS 0 WHEN THERE ARE NO REPETITIONS IN THE DATASET eg. for 1,2,3,4,5 mode should be zero but it gives 1 ! #include<iostream> #include<math.h> using namespace std; class statistical{ protected: double *dataArray; int size; public: statistical(double a[], int s){ dataArray = new double[s]; for (int i = 0; i<s; i++){ dataArray[i] =...
(C++ programming) Need help with homework. Write a program that can be used to gather statistical data about the number of hours per week college students play video games. The program should perform the following steps: 1). Read data from the input file into a dynamically allocated array. The first number in the input file, n, represents the number of students that were surveyed. First read this number then use it to dynamically allocate an array of n integers. On...
This Test: 100 pts possi A random sample of 10 students were surveyed on their social activities. The students were asked to be how many times during the previous year they had gone to a movie, sporting event of party, FR Survey Results Click the icon to view the survey results Click the icon to view the dot plot for these data Cack the icon to view the technology output for these data Frequency of Attending Movies Sports Events, and...
52.1 Three primary statistics are used to describe a variable's central tendency, defined as the average behavior of the variable. You can use these statistics, known as the mean, the median, and the mode, to draw meaningful conclusions about a variable's past behavior and to predict its future behaviar An investor is considering a stock with the following returns over the past 12 years: Year Annual Return Year Annual Return 12 10 12 The mean, also known as the arithmetic...
Create a CodeBlocks project "HW 9" Write the code to ask the user to enter the size of an array. Then create an integer array of that exact size. Ask the user to enter a maximum value and then write a loop to fill the array with random numbers with value in the range of 1 to the maximum value. For example, if the maximum value is 100, random numbers must have value 1 to 100 inclusive. Input size of...
Applications Name 7-9, find each probability assuming three cards are drawn from an ordinary deck and not replacesd. 7. Getting three jacks 8. Getting an ace, a king, and a queen in order 9. Getting a club, a spade, and a heart in order A survey of 200 college students shows the average number of text messages sent per month. Find each probability in Questions 10-13 Less than 1,000 56 61 1,000-1,999 18 18 2.000-2.999 10 13 3,000 or more...
in c++ please Assignment Instructions: MAIN FUNCTION: Ask the user how many students were surveyed. Call a function called makeArray to define an array of integers with the number of elements equal to the number of students surveyed. Call a function called getStudentData to allow the user to enter the number of hours each student spent watching Netflix into the array. Call a function called getAverage to calculate and display the average of the hours entered. Call a function called...
Consider the following program that reads students’ test scores into an array and prints the contents of the array. You will add more functions to the program. The instructions are given below. For each of the following exercises, write a function and make the appropriate function call in main.Comments are to be added in the program. 1. Write a void function to find the average test score for each student and store in an array studentAvgs. void AverageScores( const int scores[][MAX_TESTS], int...
Python: Printing Student Data Ask the user: "How many students are in the class?" Read in the number of students If there are students For each student Ask for the name of the student: "Enter the name of student:" Read in the name of the student If the student's name is greater than 24 characters Do not display this student's data Do not ask for their gpa Print: "Name of student cannot exceed 24 characters." Ask for the gpa of...