Question: Programming Fundamental 2. chapter 9 pointers You will write a program that reads in data from a text file and stores the data in a

Programming Fundamental 2. chapter 9 pointers

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

You have been provided prototypes for these functions in the starter cpp file. Note: you have been provided with two different funtion prototypes for reading data. You should only use one of these or write your own. The second prototype goes with a definition that is more challenging to write than the first.

Make sure you use good programming style. Comment all your variables, function definitions, and any calculations. Make good use of whitespace.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!