CS 2204: Homework #3

What to turn in: A legible paper copy giving your answers

Construct gawk commands to operate on an Credit card charges of John Smith, Esq., from Blacksburg, VA that will produce results specified below. Write down your awk commands below each question or use a separate sheet if you need space. If you need, you can use multiple gawk scripts connected with pipes | . Try not to, but if absolutely unavoidable, you can also use egrep . If more than one script is used, make sure to give the whole sequence in your answer.

  1. (3 points) Compute and print the total amount spent by Mr. Smith. Note that not every dollar amount reported is the money SPENT. Also note that not every line that has $ sign should count - only those lines that start with a date are what you need.
  2. (2 points) Now compute the total spending by Jan 26th inclusive; Print the lines sorted down by the dollar amount.
  3. (1 point) How much did Mr. Smith spend on gas?
  4. (3 points) Write a "fraud warning" script that prints a warning message for each transaction that is a) larger than 50 % of the total spending AND b) happens outside of the US.
  5. (2 point) What percentage of Mr. Smith's total spending happened in his home state?
  6. (3 points) Compute the total BALANCE.