Question
Programming Fundamental 2. chapter 9 pointers; // Function declarations 1) int readMovieData(int *& movies, string fileName); 2) double calculateAverage(int * movies, int size); 3) double
Programming Fundamental 2. chapter 9 pointers;
// Function declarations
1) int readMovieData(int *& movies, string fileName);
2) double calculateAverage(int * movies, int size);
3) double calculateMedian(int * movies, int size);
4) int* calculateMode(int * movies, int size, int& numModes);
5) void sort(int *& movies, int size); 6) void swap(int * a, int * b);
You will write a program that reads in data from a text file and stores the data in a dynamic array. Your program should then calculate and display the average, median and mode of the data read in. See the sample output at the end of this document.
You are provided with the data file and a start cpp file for your program. You are not required to use the starter file and you may make as many changes to the starter file as you would like. However, you must follow the requirements below and your output must match the output at the end of this document when using the provided data file (without hard-coding).
Requirements
You must use a dynamic array to store the data that you read in from the data file. The data file is a list of integers. The first integer in the list is the count of the integers that follow. Each integer that follows is the number of movies watched by a single student. When you read in the data, it would make since to read in the first number, create a dynamic array of integers that is the size of that number, and then read the remaining integers into your array.
You must pass pointers to your functions and functions should perform pointer arithmetic. You are NOT allowed to use index operators, [], anywhere in your program except when creating your dynamic array.
You should have at least five functions:
- Read data from file - Calculate the average
- Calculate the median - Calculate the mode
- Sort an array of integers
- Swap two integer values
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