Question: n this assignment youre going to write a complete C++ program that inputs a filename, opens this file, inputs the values, and analyzes these values

n this assignment youre going to write a complete C++ program that inputs a filename, opens this file, inputs the values, and analyzes these values to see if they follow Benfords law. In particular, your program analyzes the first digit of each input value, and outputs:

1. The total # of input values N

2. The counts for each digit: # of values that start with 0, # of values that start with 1, etc.

3. A histogram of the counts for digits 1..9

4. Whether the input data follows Benfords law (Yes or No)

The input file will contain at most 10,000 positive integers, one per line; you can store these into an array if you want, although arrays are not required for this assignment. For the histogram output of *s, note that the # of *s is the floor of the percentage; e.g. the percentage 16.6667% yields 16 *s. The best way to compute the floor of a real number is to use the built-in floor function available by #include .

For the purposes of this assignment, assume that a set of values adheres to Benfords law if all of the following are true:

a. The % of 1s falls in the range 28.0 .. 38.0, inclusive

b. The % of 2s falls in the range 15.0 .. 21.0, inclusive

c. The % of 3s falls in the range 10.0 .. 13.0, inclusive

d. The % of 4s is strictly less than the % of 3s

e. The % of 5s is strictly less than the % of 4s

f. The % of 6s is strictly less than the % of 5s

g. The % of 7s is strictly less than the % of 6s

h. The % of 8s is strictly less than the % of 7s

i. The % of 9s is strictly less than the % of 8s

The file contains the following numbers:

34

0123

22184

123456

9811

7812

123

12345

51613

2239

31998

43

The output of the data should be:

N: 12

Counts: 1,3,2,2,1,1,0,1,0,1

1: ************************* (25%)

2: **************** (16.6667%)

3: **************** (16.6667%)

4: ******** (8.33333%)

5: ******** (8.33333%)

6: (0%)

7: ******** (8.33333%)

8: (0%)

9: ******** (8.33333%)

Beneford's law? No

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!