Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that uses scanf within a nested for loop to read each year ( row ) of data breach counts by month (

Write a program that uses scanf within a nested for loop to read each year (row) of data breach counts
by month (column) into a 2D array from a file. The file contents are:
179161193217300268201170133156164245
259126174143214351531973258197219134
2021282502854675343765371126772871316
where rows are years (2021,2022,2023) and columns are number of data breaches in the US by month
(Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec). You may use constants #define YEAPS_OF_DATA
3 and #define MONTHS_PER_YEAR 12 for the loop conditions of the nested for loop and for the 2D array
dimensions. Once all monthly data breaches are read into your program, calculate, and print by year:
The total number of data breaches for each year
The month with the maximum data breaches for each year
The mean and standard deviation of monthly data breaches for each year
a. Define a function for calculating the mean
i. mean =(double)(total_data_breaches_per_year)??(double) MONTHS_PER_YEAR
b. Calculate the standard deviation (reference lecture Week5_Class1 slide Figure 7.2)
i.standarddeviation =i=1N(xi-(x))2N2 where xis the mean, ifor month, ??& N=12
Section D) Requirements for Part (b):
Create and edit a file named program2b_yourloginName_data_breaches.c
a. Note that all C program source code files should end with a .c extension
Use a multiline comment at the top of your .c file that includes:
a. Course and assignment number
b. Your name
c. Purpose of the program (e.g.1-3 sentences)
Use a comment in the main body above each step of your approach/algorithm. Complete & test
one step at a time. Use functions to keep main function minimal & algorithm details in functions.
a. e.g./* A nested for loop to read in data from file ... and store */
b. e.g./ Calculate and display ... annual totals */
c. e.g./* Calculate and display ... month with max data breaches ...*/
d. e.g./* Calculate and display mean and standard deviations ...%
Output floating point results displayed to the user formatted with 3 decimal places
When your program is complete, use the goc command to compile it into an executable file
(remember -Im to link library for math.h for sqrt), and then run the resulting executable file. Use
a multiline comment at end of your .c file showing command line output from a sample run
Before doing a sample run, calculate by hand what the results should be for one of the years.
Show your work in a separate submission file. See Section F Submission.
/" Sample Run
2021: 179161193217300268201170133156154245
2021: annual data breaches =2387
2021: month of max breaches is May
2021: mean is 198.197 and standard deviation is 47.921
-...[2022 output here]
2023: ...
2023: annual data breaches =..
2023: month of max breaches is ..
2023: mean is ... and standard deviation is ...
%
image text in transcribed

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

Transactions On Large Scale Data And Knowledge Centered Systems Vi Special Issue On Database And Expert Systems Applications Lncs 7600

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Stephen W. Liddle ,Klaus-Dieter Schewe ,Xiaofang Zhou

2012th Edition

3642341780, 978-3642341786

More Books

Students also viewed these Databases questions