UPC Receipt Calculator

You are to write a program that simulates a self-checkout style cash register with a bar code scanning device.  Imagine a grocery cart of items at a check-out stand.  Each item passed through the scanner returns a UPC code. Your program must take the list of UPC codes and produce the sales receipt.

Input
The input data is a list of UPC's (including check digit).  Each line of input contains a 12-character string representing a UPC.  Input is terminated by EOF.
All the input data will be read before any output is produced.
There will be at most 500 data items.
A file of UPC codes for all the products available for sale.  It isn't necessary for you to see the entire list, but an excerpt is provided below.

Output
A list of products, including quantity and subtotal.
The total price of the entire purchase.
The total number of items purchased.
A list of invalid UPC's. If there are any invalid UPC's, display them (also in the order they appeared in the input).  For each invalid item indicate the reason it was rejected:
(Note: The program does not display any prompts to the user.)

Functions
Read the list of UPC's.
For each UPC, verify the check digit, using the algorithm below. If the verification fails, that means the scanner made an error reading the label, and that item is to be skipped and an error reported.  If the UPC is valid, you can try to look it up in the database.  If it isn't in the database, the clerk in our IT department forgot to add the product to the database and the customer gets it for free.
Count the number of times each product appears.
Add the product price to a total (after converting it to an integer).
Display the products in the order they appeared in the input.


Excerpt from database: (plain text file: productDB.txt)
{"088270221332","Rainer Cherry Soda","1.09"},
{"000420200004","Twix 3.02OZ","1.29"},
{"880607148868","SAMSUNG GALAXY s2","678.23"},
{"075944869020","Kenneth Cole Reaction FAST CASH XL SHOES","242.22"},
{"081380201850","NORDSTROM RACK ivory skirt small","89.16"},
{"013556500009","bojolais village","24.55"},
{"089784300292","lighting","8.44"},
{"070462459937","l.e.i. lime green tank S","12.99"},
{"002021804308","Pantene hair solution 302 ml","9.75"},
{"088722379598","Nike shorts","23.32"},
{"003920897309","Brinks door lock","19.44"},

Sample Input (from standard input)
000420200004
000420200001
000420200004
088270221332
000420200004
088722379598
123123123125
000420200004
880607148868

Sample Output (to standard output)
	Purchases
Twix 3.02OZ                                         (  4)          5.16 
Rainer Cherry Soda                                  (  1)          1.09 
Nike shorts                                         (  1)         23.32 
SAMSUNG GALAXY s2                                   (  1)        678.23 
                                              TOTAL (  7)        707.80

	Invalid Items
000420200001 check digit doesn't match
123123123125 product doesn't exist in the database



Another Sample Output
	Purchases
Twix 3.02OZ                                         (499)        643.71 
Rainer Cherry Soda                                  (  1)          1.09 
                                              TOTAL (500)        644.80
Check Digit Algorithm
A barcode scanner for Universal Product Codes (UPCs) verifies the 12-digit code scanned by comparing the code's last digit (called a check digit) to its own computation of the check digit from the first 11 digits as follows:
1. Calculate the sum of the digits in the odd-numbered positions (the first, third, …, eleventh digits) and multiply this sum by 3.
2. Calculate the sum of the digits in the even-numbered positions (the second, fourth, ..., tenth digits) and add this to the previous result.
3. If the last digit of the result from step 2 is 0, then 0 is the check digit. Otherwise, subtract the last digit from 10 to calculate the check digit
4. If the check digit matches the final digit of the 12-digit UPC, the UPC is assumed correct