Your program seems to work if I feed it this two line data file
2014 R T 1
2014 R T 2
Does this data file work for you in your environment?
What data file are you feeding it?
Logan L.
asked 08/24/22Write a script called labscript3.awk that will print out all orders shipped in 2014. Print out region, item type and total profit. At the end, it should print out the average total profit (for these orders only). (5 points)
Tried:
BEGIN {
printf "%-25s %-16s %-10s\n","region","item type","total profit"
print "============================================================="
cnt=0
sum=0.0
}
{
if($1==2014){
printf "%-25s %-16s %.2f\n",$2,$3,$4
++cnt
sum += $4
}
}
END {
print "============================================================="
printf "The average total profit is : %.2f\n", sum/cnt
}
but it does not print the correct thing.
Your program seems to work if I feed it this two line data file
2014 R T 1
2014 R T 2
Does this data file work for you in your environment?
What data file are you feeding it?
Get a free answer to a quick problem.
Most questions answered within 4 hours.
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.