Question
Write an awk script that produces a report from an input file. The report summarizes sales data as recorded for sales stations. The input file
Write an awk script that produces a report from an input file. The report summarizes sales data as recorded for sales stations. The input file contains sales data for several years, however, your report should only list data for the year 2014.
The awk script file name must be "z123456.report", where z123456 is your Z-id. The awk script is invoked from the command line with an input file that contains data for multiple years:
awk -f z123456.report inputfile. txt
The lines in the input file have the following fields:
- year: four digit integer number
- month: three letter abbreviation of a month
- station: one letter station code
- sale amounts: floating point numbers, with 2 significant digits. Each input line will have at least one and at most 10 amount fields.
2011 Jan X 29.44 17.33 43.21 2014 Jan Y 32.32 12.12 99.00 1.99 2012 Jan X 321.11 12.34 10.99 2012 Feb Y 1.99 12.75 2012 Feb X 32.99 65.78 98.76 2014 Jan Y 12.99 17.44 21.34 2012 Mar X 11.45 ...
Your awk script should produce a report that lists the 2014 sales amount per month and station. In addition the report should list the sum of all sales per station for the year 2014, the total sales for the year, and how many records from the input file were processed.
Here is an example of the script invocation using the sample input file provided above:
awk -f z123456.report input file.txt Sales Data for year 2014 Jan: 145.43 Jan: Mar: Aug: 343.88 Dec: Nov: 410.09 Dec: 331.76 51.77 10.00 29.97 Station volume for 2014 X: 1095.73 Y 197.20 29.97 Total: 1322.90 7 records processed
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started