Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ libraries iostream, iomanip, cstring, fstream, cstdlib, cmath This program takes its inputs from a file that contains numbers. The program reads them in as

C++ libraries iostream, iomanip, cstring, fstream, cstdlib, cmath

This program takes its inputs from a file that contains numbers. The program reads them in as type double. The program outputs to the screen the standard deviation of the numbers in the file. The file contains nothing but numbers of type double separated by blanks and/or line breaks. The standard deviation of a list of numbers x1, x2, x3, and so forth is defined as the square root of:

((x1 a)2 + (x2 a)2 + (x3 a)2 + ) / (n - 1)

Where the number a is the average of the numbers x1, x2, x3, and so forth and the number n is the count of how many numbers there are. The answers should be given with 3 decimal points precision.

The program has to ask the user for the file name and has to check to see if the file exists (use the string Enter file name: for the question). If it does not exist, the program must output (via cerr) an error message: Input file opening failed. and then exit with code 1.

Your program should define at least one function.

A session should look exactly like the following example (including whitespace and formatting - note that there is no whitespace at the end of each of these lines and each printed line has a newline at the end), with all manners of different numbers for inputs and the output:

Enter filename: nums.txt The standard deviation is 1.581 

The accompanying input file in this example, could look like this (note the separation by one or more spaces):

6 7 8 9 10 

or like this (note the separation by either spaces or newline characters):

6 7 8 9 10 

MAJOR REQUIREMENT: At least ONE function.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Types of Interpersonal Relationships?

Answered: 1 week ago