Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that takes its input from a file of numbers oftype double. The p

ID: 3613582 • Letter: W

Question

Write a program that takes its input from a file of numbers oftype double. The program outputs to the screen the average,variance, and standard deviation of the numbers in the file. Thefile containes nothing but numbers of type double separated byblanks and/or line breaks. The standard deviation of a list ofnumbers n1, n2, n3, and so forth, is defined at the square root ofthe variance of the numbers. The variance can be obtaines asfollows: [(n1 - a) squared + (n2 - a) squared + (n3 - 1) squaredand so forth] divided by the total numbers in the file. The lettera is the average of the numbers n1, n2, n3,...For example, assumethe file contained 1, 2, and 3. The average would be 2 and thevariance would be: = [(1 - 2) squared + (2 - 2) squared + (3 - 2)squared]/3 = [-1 squared + 0 squared + 1 squared]/3 = [1 + 0 + 1]/3 = 2/3 = 0.666 Then the standard deviation is simply the squareroot of the variance (0.8165). Hint: Write your program so that itfirst reads the entire file and computes the average of all thenumbers, then closes the file, then reopens the file and computesthe varince and standard deviation. NOTE: The program must includeample documentation to explain its purpose.

Explanation / Answer

please rate - thanks #include #include #include using namespace std; int main() {int i=0; double n,sum=0,avg; ifstream in; ofstream out; in.open("input.txt");          //open file if(in.fail())            //is it ok?    { coutn)     {sum+=n;      i++;      } avg=sum/i; //in.close();   close and open file didn't work in.clear();      //this 2 instruction"rewind" the file in.seekg(0L,ios::beg); /*in.open("input.txt");          //open file if(in.fail())            //is it ok?    { coutn)     sum+=pow(n-avg,2); sum/=i; cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote