Write a program that can be used togather statistical data about the number of m
ID: 3618163 • Letter: W
Question
Write a program that can be used togather statistical data about the numberof movies college students see in a month. The program shouldperform the
following steps:
- Ask the user how many students were surveyed. An array of
integers with this many elements should be dynamicallyallocated.
- Allow the user to enter the number of movies each student sawinto the array.
- Calculate and display the average, median, and mode of thevalues entered.
(Use the functions you wrote in problem 6 and 7 to calculate themedian and mode.)
Input Validation: Do not accept negative numbers forinput.
int main()
{
int *dyn_array;
int mode, students;
float avrg;
do
{
cout << "How many students will you enter? ";
cin >> students;
}while ( students <= 0 );
dyn_array = create_array( students );
//this funtion creates a dynamic array
//and returns its pointer
enter_data( dyn_array, students );
//use 'pointer' notation in this function to
//access array elements
//accept only numbers 0-100 for movie seen
mode = get_mode( dyn_array, students );
//check out pc6 for an explanation of 'mode'
//median = median( dyn_array, students );
//don't do median in this exercise
avrg = average( dyn_array, students );
//should be trivial
cout << "The array is: ";
showArray( dyn_array, students);
cout << endl;
cout << "The Mode is " << mode << ". ";
cout << "The average is " << avrg << ". ";
delete [] dyn_array;
return 0;
}
Explanation / Answer
please rate- thanks #include using namespace std; double median(int *, int); int get_mode(int *, int); int *create_array(int); void getinfo(int *, int); void sort(int [], int); double average(int *, int); int main() { int *dyn_array; int students; int mode,i; float avrg; do {cout > students; }while ( studentsRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.