1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
e-lub [12.9K]
3 years ago
8

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. Here is an example of input sales data
Computers and Technology
1 answer:
Hatshy [7]3 years ago
8 0

Answer:

Script is given below

Explanation:

Below is the AWK code for the Report.I have used the sample data that your have shared in the question.

AWK code-

echo "Hello World!"

echo "2011 Jan X 29.44 17.33 43.21" > inputfile.txt

echo "2014 Jan Y 32.32 12.12 99.00 1.99 " >> inputfile.txt

echo "2012 Jan X 321.11 12.34 10.99" >> inputfile.txt

echo "2012 Feb Y 1.99 12.75" >> inputfile.txt

echo "2012 Feb X 32.99 65.78 98.76" >> inputfile.txt

echo "2014 Jan Y 12.99 17.44 21.34" >> inputfile.txt

echo "2012 Mar X 11.45" >> inputfile.txt

awk -F" " 'BEGIN{ X_sum=0;

print(" Sales Data for year 2014")

print("========================")

}

{ if($1=="2014")

{

print($2,":", $4+$5+$6+$7+$8+$9+$10+$11+$12+$13)

}

if($3=="X")

{

X_sum=X_sum+$4+$5+$6+$7+$8+$9+$10+$11+$12+$13

}

if($3=="Y")

{

Y_sum=Y_sum+$4+$5+$6+$7+$8+$9+$10+$11+$12+$13

}

if($3=="Z")

{

Z_sum=Z_sum+$4+$5+$6+$7+$8+$9+$10+$11+$12+$13

}

 

}

END { print(" ========================")

print("Station volume for 2014 is:")

print("X:" ,X_sum )

print("Y:" ,Y_sum )

print("Z:" ,Z_sum )

}

' < inputfile.txt

You might be interested in
An iterative algorithm uses a loop to solve the problem, while a recursive algorithm uses a method that calls itself. (true, fal
loris [4]

Answer:

True.

Explanation:

An iterative method uses a loop to solve the problem either it can be for,while or do-while loop.Iterative methods are easy to implement than recursive problem.

While recursion uses the same method to call itself.Recursive methods are not easy to implement as compared to iterative method.It contains following things:

  1. base case.
  2. Some calculation.
  3. Recursive call.
6 0
4 years ago
Write a function square_evens(values) that takes a list of integers called values, and that modifies the list so that all of its
Mice21 [21]

Answer:

#create the function

def square_evens(values):

   count_Value = 0

   #loop loop for iteration

   for i in values:

       #check for even number

       if (i) % 2 == 0:

           values[count_Value] = i * i  #store the square in the same index

       count_Value =count_Value + 1

   print(values)  #print the list

# list of integers

values = [1, 2, 3, 4, 5, 6]

#calling the function

square_evens(values)

Explanation:

The above code is written in python. first, create the function square_evens() which takes one parameter of the list.

inside the function declare the variable and then take a for loop for traversing each element in the list. Inside the for loop, we take the if-else statement for checking the number is even. if the number is even then stored the square of that value in the same list. To store the square value in the same index, we take the count variable for tracking the index.

After the all element in the list checked, the program terminates the loop and then print the updated list on the screen.

Outside the function, create the list with an integer value and then calling the function with passing the list argument.  

NOTE: In the python programming, please keep the indentation in code.

5 0
3 years ago
Linda is searching for a new job. Which information would her potential employers likely review in her social profile?
nasty-shy [4]
The answer will be A they would wanna know about her work history
3 0
3 years ago
Read 2 more answers
Identify a true statement to determine the number of columns in a web table.
Rainbow [258]
B (each column gets a caption)
7 0
3 years ago
The ______ is the information center that drivers need to refer to when they're NOT scanning the road.
Kruka [31]

Answer:

The  DIC (Driver Information Center)  is the information center

Explanation:

Scanning the road means that the road has to looked and analyzed for traffic jams, the cars that are coming close together and how fast the driver is driving etc, to keep ourselves safe from accidents.

If the driver is not scanning the road, then DIC will help the driver to find lots of useful information which keeps himself as well as the peer drivers on the road safe and thus avoiding accidents where by saving lives and heavy injury.

DIC will have Traffic details, navigation, entertainments, traffic signs, etc.

8 0
3 years ago
Other questions:
  • Why would someone need to use tools like IECacheView or MyLastSearch on a system? Do companies have the right to search a workst
    11·1 answer
  • Software that gives network administrators the ability to provide computer assistance from a central location by allowing them t
    15·1 answer
  • The number of semi skilled workers in an industry find themselves out of work, when improvements in technology render their jobs
    15·1 answer
  • Could someone give an example or tell me what all of these mean? (For internet source citing)
    10·1 answer
  • FOR DIGITAL DESIGN/ PHOTOGRAPHY
    5·2 answers
  • Importance of professional education​
    15·1 answer
  • Which line of code in this program is MOST likely to result in an error
    15·2 answers
  • Im drinking coffee. and working on school and watching a show. Whos with me?
    9·1 answer
  • How do i stop my computer from automatically connecting to a wireless network
    5·1 answer
  • Computer are most wonderful creation of 21st century how ?​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!