Write a program that calculates basic statistics for a set of numbers stored in a file. Make sure to allow the user to tell you the name of their file and to check for file open errors. The data in the file will be a space-separated list of numbers. You won't know the length of the list ahead of time. You'll need to calculate the average and standard deviation of the list as well as determining the maximum and minimum for the data.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Use C++. This lab will help you practice simple data processing from a file where you don't know the amount of information in the file ahead of time. (It also provides some refresher in basic statistics.) (classes may or may not be of use here...you decide!)

Write a program that calculates basic statistics for a set of numbers stored in a file. Make sure to allow the user to tell you the name of their file and to check for file open errors.

The data in the file will be a space-separated list of numbers. You won't know the length of the list ahead of time. You'll need to calculate the average and standard deviation of the list as well as determining the maximum and minimum for the data. To refresh your memory, the standard deviation is the square root of the variance. And the variance? Well, it is found as discussed in this brief paper.

You can choose the actual values to use for the data. Make sure to do enough different sets of data to test your program well!

Remember that your program cannot know how many data points are in the file ahead of time!

Don't forget to read the file's name from the user and protect your program against any errors that may occur during the opening of the file.

As always, try to use functions to break up the program into more manageable pieces.

As an example, you might have the data file contain:

1 2 3 4

5 6 7 8

 

9 10

and the program interaction might look something like (the parts underlined are typed by the user):

 

$ ./statnumbs.out

 

Welcome to the Number Statistics Program!!!

 

Please enter the name of your data file:  bob.dat

 

I'm sorry, I could not open 'bob.dat'.  Please enter another name:

values

 

File 'values' opened successfully!

 

Reading data from 'values'...

 

Calculating...

 

Done processing data!

 

For your data, the statistics are as follows:

 

         Count:  10

   Minimum:  1

     Average:  5.5

  Maximum:  10

        StdDev:  3.02765

 

Thank you for using the NSP!!

 

Endeavor to have an undulating day!

 

$

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education