Assignment: Write a C++ program that uses functions to process a set of operations. These operations include reading data from a file, calculating average, standard deviation, and variance of a set of numbers, and calculate the future value on an investment.

Process and sample run:

a) Function 1: A void function that uses parameters passed by reference representing the name of a data file to read data from, amount of principal in an investment portfolio, interest rate (any number such as 5.5 for 5.5% interest rate, etc.), number of times the interest is compounded, and the number of years the money is invested.

b) Function 2: A double function that accepts the name of a file as its parameter and returns the average of the numbers. Note, you must open the file, read data from it and close the file. If the file does not exist, return -1000 for the average.

c) Function 3: A double function that accepts the name of a file and a variable representing the average of the numbers as its parameters and returns the variance of the numbers. Note, you must open the file, read data from it and close the file. If the file does not exist, return -1000 for the variance. The symbol represents the total of the values. is the average of the numbers.

Formula: see image.

d) Function 4: A double function that accepts the variance of numbers as its parameter and returns the standard deviation of the numbers. Standard deviation is the square root of variance. If the variance is negative, return -1000 for the variance.

e) Function 5: A double function to calculate and return the future value of investment using compound interest. This function accepts what it needs as parameters and will return the future value. Use the header: double getFutureValue(double principal, double rate, int times, int years). Here is the formula to calculate Future Value of an investment:

Future value = principal (1 + rate / times)times * years

Note: In your code, you must convert the rate to a decimal value by dividing rate by 100. Otherwise, the calculation will be wrong.

f) Function 6: A void function to display the values of all input and calculated values using a format similar to the output shown in the sample run.

In a main function, call your functions to process data. Check for the existence of the input data file. If the file does not exist, the statistics about your data file will not be displayed and an error message will be displayed.

Make sure to ASK the user for the necessary input. For example, ask the user for the name of a file rather than hard-coding it in your code. This makes your testing life much easier.

Here is a sample run:

Assuming our data file is the following, we can expect the following results. Remember that the code must work on any input data file. NOTE that the first line of the input data file is always a string of characters used as the header of the file that should be read before you read the data.

CONTENTS of the DATA FILE

STUDENT DATA
23.87
15
19.87
-78
10.01
55

Average = 7.6250
Variance = 2009.9900
Standard Deviation = 44.8329
Initial balance = 1000.0000
Interest rate = 5.5000
Compounded times = 4
Number of years = 20
Future Value = 2981.7373

If the data file does not exist, we could expect the following results for the sample statistics:

Average = -1000.0000
Variance = -1000.0000
Standard Deviation = -1000.0000
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.