Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is the code that is wrong, I need to have it so that it prints Total, max, min, and average all in order. It

This is the code that is wrong, I need to have it so that it prints Total, max, min, and average all in order. It should be fairly easy, please use printf so that all 4 of those look like a similar format. This is Unix (Mac Terminal). image text in transcribed
image text in transcribed
For part 2, which is your homework you need to turn in, modify the program so that it also prints out the maximum and minimum values, as below: elvis> ./stats.awk + items: 4 Total: 10.000000 Maximum: 4.000000 Minimum: 1.000000 Average: 2.500000 elvis Note that if there is no input, it should still just print that there were no items: elvis> ./stats awk 0 # items: 0 elvis> elvis> ./stats.awk *D # items : 0 elvis # stop when we get a zero $1 == 0 { exit } # jumps to END condition # special steps for first line only NR == 1 { max $1 } # All lines (including first) { total + $1 ) # print results at end of data (or on zero) END { if (NR == 0 11 (NR == 1 && $1 == 0)) { printf("# items: ") } else { if ($1 == 0) { # don't count the sentinel value NR - 1 } printf("# items: %d ", NR) printf("Total: %f ", total) printf "%-7s : %d " x 4, "Min", min(OF), "Max", max(OF), printf("Maximum: %d\t", Maximum)

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

Databases And Python Programming MySQL MongoDB OOP And Tkinter

Authors: R. PANNEERSELVAM

1st Edition

9357011331, 978-9357011334

More Books

Students also viewed these Databases questions

Question

Summarise the scope of HRM and the key HRM functions

Answered: 1 week ago

Question

Describe the key uses of CPM and Gantt charts.

Answered: 1 week ago