Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ The program makes use of arrays and pointers in a class definition. In this assignment, you will create a class called MovieStatistics . The

C++

The program makes use of arrays and pointers in a class definition. In this assignment, you will create a class called MovieStatistics. The class contains:

an integer that keeps track of the number of students surveyed

an array that keeps track of the number of movies watched by each student surveyed.

The class private variables are:

an int pointer called movies_pointer

an int variable called numOfStudents

Class functions are described below:

Class Constructor. This function takes in an int and an int array. Suppose that it is invoked as follows:

int my_mov_array[5] = {23, 5, 6, 1, 5}; MovieStatistics my_movies(5, my_mov_array); The Constructor should:

set 5 (the first argument to function invocation) into numOfStudents class private variable

Create a 5 element int array and place address of newly created array into movies_pointer class private variable

Copy contents of the incoming parameter array (2nd parameter) into the newly created dynamic array whose address is maintained in movies_pointer

Do not copy incoming pointer into the class private pointer!

Class destructor : Release the array whose address is maintained in movies_pointer.

print. Print out the contents of the dynamic array whose address is maintained in the movies_pointer variable. Print out the average of the array contents.

sort_desc. Sort the contents of the dynamic array whose address is maintained in the movies_pointer variable in descending order

This assignment should be implemented in 3 files, which are:

MovieStatistics.h

MovieStatistics.cpp

assignment9_tester.cpp

Use the following code to test the MovieStatistics class

#include #include #include using namespace std; #include "MovieStatistics.h" int main() { int movies_numbers_Spring[7] = { 3, 6, 1, 3, 4, 9, 5 }; int movies_numbers_Fall[4] = { 7, 3, 9, 1 }; MovieStatistics stu_movies1(7, movies_numbers_Spring), stu_movies2(4, movies_numbers_Fall); cout << "**********Survey Data from Spring 2014************** "; cout << " -- Before Sort -- "; stu_movies1.print(); stu_movies1.sort_desc(); cout << " -- After Descending Sort -- "; stu_movies1.print(); cout << "**********Survey Data from Fall 2014************** "; cout << " -- Before Sort -- "; stu_movies2.print(); stu_movies2.sort_desc(); cout << " -- After Descending Sort -- "; stu_movies2.print(); return 0; } 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases A Tour

Authors: Shashi Shekhar, Sanjay Chawla

1st Edition

0130174807, 978-0130174802

Students also viewed these Databases questions

Question

G. Identify common types of support materials for presentations.

Answered: 1 week ago

Question

l Summarize the process of evaluating HR performance.

Answered: 1 week ago

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago