Assignment 1 - Processing the shopping list

due September 29th

The purpose of this assignment is to review the use of  reading and writing text files, writing functions, and formatting output.

Part 1 Detail

Read in the shopping list file, partially shown below. This file consists of a heading line and a list of items and their cost.  

The Shopping List File

Shopping List
apple 1.05
banana 0.50
book 139.95
eraser 0.509
flashdrive 9.99
folder 1.00
highlighter 0.98
keyboard 20.15
...

You are to process the input data and produce the report file shown below.  The output format must match exactly that shown below, except that you are to calculate the total (that is the sum of the subtotals, between $800 and $899).  The the column widths are 12, 10, 8, and 12.

Output Report File

Item              Cost     Tax    Subtotal
-----------     ------   -----    --------
apple             1.05    0.00        1.05
banana            0.50    0.00        0.50
book            139.95   12.60      152.55
eraser            0.51    0.05        0.55
flashdrive        9.99    0.90       10.89
folder            1.00    0.09        1.09
highlighter       0.98    0.09        1.07
keyboard         20.15    1.81       21.96
...
                                  --------
                           Total    8??.??
The tax rate is 9%, but there is no tax on the banana, the apple, or the water.

Program requirements

  1. Make sure you check for successful file opens.
  2. Include at least 3 named constants.  Suggestions: input file name, output file name, and tax rate.
  3. Include at least 2 functions besides main().  Suggestions: a function to return the tax amount, a function to write the headings.
  4. Place the function definitions below main() and function prototypes above main().
  5. You may not modify the input file.