Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please note that when it says Your program should also declare, define, and use functions... it's asking to make user created functions where the function
Please note that when it says "Your program should also declare, define, and use functions..." it's asking to make user created functions where the function has 3 parts, namely a Declaration, a Call, and a Definition as outlined in the example below:
#include using namespace std; int sum (int x, int y); //declaring function int main() { int a = 10; int b = 20; int c = sum (a, b); //calling function cout
If you can format the user created functions like this then that would be the prefered way to answer this question if possible. Thank you!
Problem A: Computing statistics on a data set. (20 points) Write a program that reads a list of integers stored in a file and computes a count of how many times each number occurs in the data set. Specifically, your program should compute a count of how many times each integer number stored in the file occurs, and compute the standard deviation, average, minimum, and maximum value for the numbers stored in the file. You may assume that there is at least one number stored in the file, and that each value stored in the input file will range between 0 and 149 (so, algebraically: 0149, for each number x stored in the input file). You may also assume that each of the numbers in the file will also be separated from each other by a space or new line, and that the input file will reside in the same directory as your program executable Your program should declare, define and use a function or functions for finding the maximum value, minimum value from the data stored in the input file. Your program should also declare, define and use functions to compute the arithmetic mean value (average), and standard deviation of the data stored in the input file For this assignment, the formula that you should use to compute the standard deviation is i=1 Where is an individual value is the mean/expected value N is the total number of values Your program should prompt for the name of a file, and obtain the numbers from that file. The output should be written to the file named "statistics.txt". The output should be in the forma a two column list where the first column is a list of the numbers read in from the input file, the second column is the count of the number of times each number occurs the list of numbers from the file. Finally, the output should be sorted into descending order Note, you will need to create your own input files for testing. For example, if the file "nums.txt" contains the following values: 12 3 5 2 30 98 3 7 5 12 An example run of your program using the file nums.txt as input would be as follows: Please enter an input file name: nums.txt The output to the file "statistics.txt" should be as follows: N Count 98 1 30 1 12 2 Min: Max: Avg: Std. Dev. 27.89 (Updated to Population Standard Deviation) 98 17.7 Note, your program should function correctly on any data set that conforms to the specifications documented above, so you should be sure to test your on more than one data set. Also, your program should ensure that the input and output files open without error. If an error occurs when opening a file, your program should print an error message and exit appropriately Hint - use an array to keep a count of the number of times a specific number appears in a file. Write, test, and correct your program. Have all the functions, including main, in a single file with the function definitions after main. When you are done, name the source code file Kusername>_5A.cpp (where you replacewith your U of M email address), and submit it using the Homework 5 Problem A link on the class Moodle page. Remember to follow the naming convention diligently
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