Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ code for the following Benfords Law: Wikipedia. A practical application of Benford's law is the detection of fraud by the IRS, you

Write a C++ code for the following Benfords Law: image text in transcribed
Wikipedia. A practical application of Benford's law is the detection of fraud by the IRS, you can read more about that hers In this assignment you're going to write a complete Cer 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 Benford's law (Yes or No) Here's an example screenshot of your program output for the input shown earlier, assumed to be in the file example.txt xample.txt 12 ounts: 1,3,2,2,1,1,0,1,8,1 * (25x) 34 0123 22184 123456 9811 7812 123 12345 51613 2239 31998 43 (16.6667%) (16.6667%) : (8.33333%) (8.33333x) (8.33333%) (8.33333x) (0%) (0%) eneford's law? No 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, eg. the percentage 16.6667% yields 16-s. The best way to compute input file will contain at most 10,000 positive integers, one per line: you can store these into an array if the floor of a real number is to use the built-in noor function available by #reude eemathy For the purposes of this assignment, assume that o set of values adheres to Benford's law if all of the following are true a. The % of 1's falls in the range 28.0 .. 380, inclusive b. The % of 2's falls in the range 150-210, inclusive c. The % of 3's falls in the range 100.. 130, inclusive d. The % of 4's is strictly less than the % of 3's e. The % of 5's is strictly less than the % of 4's f. The % of 6's is strictly less than the % of SS g. The % of?S is strictly less than the % of 6's h. The % of 8's is strictly less than the % of 7's i. The % of Ss is strictly less than the % of 8's HINT: Benford's law is based on the firs digit of each value. The easiest way to obtain the first digit is to input the value as a string, and use 101 to obtain the first digit. This implies the digit ill be a character, eg. 2 and not an integer 2. To count each digit, you can use 10 counter variables, or an array with 10 elements (representing digits 0.9)

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

Recommended Textbook for

Beginning Microsoft SQL Server 2012 Programming

Authors: Paul Atkinson, Robert Vieira

1st Edition

1118102282, 9781118102282

More Books

Students also viewed these Databases questions