copyright Steve J. Hodges   http://steveh.net/cs19/cs19-hw05.html

CS19 Fall 2017

Assignment 5 (Looking Out for Number One)

Directory Name

19-5

Resulting Executable (from your Makefile)

p5

Background

The natural world is full of hidden and beautiful mathematics. The whorls of a conch shell hide the Fibonacci sequence and its Golden Ratio, plants grow in fractal patterns, and comets trace hyperbolic patterns through the solar system. All those beautiful patterns hide in the grungy data of human observation. So, what are the populations of every town in California and the number of friends by the members of MySpace or Facebook hiding from you?

Program Description

Define a class called DigitAnalyzer that implements a Linked List (by serving as a List class as described in class) that can store integers and perform some analysis on them. Your linknode class may (at your preference) store your integer data in the linking node object itself for your convenience. Your List class must support at a minimum, the following functions:

Main and program data files

Write a main function that reads an unspecified number of lines of text from a regular text file by getting the filename from the command line. If no filename is provided on the command line, your program should instead read its input (not a filename) from STDIN. Your program should exit on an invalid text file (name.) You may assume that no line of text will consist of more than 255 characters. Every line will contain, at most, one comment and, at most, one integer. Some lines may be blank. Comments will be contained within specific start "(*" and end "*)" delimeters, and both the start and end delimeters will always occur on the same line. Integer data may come before, or after comments if the line has both. Read each integer and store it in your linked list. Once you have completed all input, use the functions you have written to display (in a table) the total number of enteries, the average value (mean), the standard deviation, the number of entries that begin with each digit, and what percentage (formatted as a percentage with one decimal place example: 7.5%) of the total input that digit accounts for.

Observe

(10 points) Write up any common observations that you make about these data sets in a readme.txt file.

What to "Turn-In"

Since this is a multi-file project, I will collect the directory 19-5 and all of its contents. You are required to ensure that only the necessary .h and .cpp files, a working makefile, and an optional readme.txt file are present. The binary program resulting from compiling your project should be called "p5". You will loose points if any other files are present, unless you have a 'make clean' option that removes them.

Sample Data Files

Standard Deviation

formula and description

Sample Run

[steveh@pengo Solutions]$ ./p5 randomValues.txt 
Leading Digit Analysis Sample Solution
2200 entries.
mean is 50658.
stddev is 23215.
digit	count	%
0s	0	0.0%
1s	230	10.5%
2s	233	10.6%
3s	253	11.5%
4s	236	10.7%
5s	241	11.0%
6s	250	11.4%
7s	240	10.9%
8s	266	12.1%
9s	251	11.4%
[steveh@pengo Solutions]$