Well-Built Cabinet Distributors, Inc. recently received an electronic catalog of cabinets from their leading manufacturer, Woodcraft. Unfortunately, the format of the data is not consistent with that expected by Well-Built's inventory software. For this problem, you will construct a program that reformats the Woodcraft catalog for use by the inventory software.
Input will be formatted as from a comma-delimited ASCII file. Your program must read all input from the standard input file. Each line in the input has a maximum length of 64 characters and contains the following fields:
The records are presented in ascending order by Style Code. You may assume that all fields will be consistent with the lengths given, and that all fields will contain appropriate characters.
Output will consist of a reformatted catalog. The reformatted catalog file will be a comma-delimited ASCII file. The first record in the file must be the following:
Item Id,Item Desc,Item Price
Each remaining record in the file will have a maximum length of 50 characters and contain the following fields:
The Item Id is formed by concatenating the Style Code and the Description. If the Style Code is less than three characters long, it must be left-filled with zeros to three characters. If the Item Id exceeds 13 characters, then the record is rejected.
The Item Desc is formed by concatenating the Style Name, a hyphen, and the Extension. If the Style Name is missing, use the Style Name from the first record of the corresponding Style Code group. If this first record has no Style Name either, then reject the record. If the Extension is not present, then Item Desc is the same as Style Name (no hyphen). If Item Desc exceeds 30 characters, then it must be truncated on the right.
The Item Price is formed by formatting the Unit Price as dollars and cents. If Unit Price is not present, then Item Price = 0.00.
23,CHAMPAGNE,BASE36,3" RECESSED TOE KICK,8900 23,,BASE54,,11000 25,LAUREL,CNR24LT,,15000 107,COLONIAL,BASE54WSIDEJAM 202,SAGEBRUSH,OVRHD54P,USE WITH HDWARE KIT #3207 221,ALVEA MODERN,BASE36 221,ALVEA MODERN,OVRHD54WCAP
Item Id,Item Desc,Item Price 023BASE36,CHAMPAGNE-3" RECESSED TOE KICK,89.00 023BASE54,CHAMPAGNE,110.00 025CNR24LT,LAUREL,150.00 202OVRHD54P,SAGEBRUSH-USE WITH HDWARE KIT ,0.00 221BASE36,ALVEA MODERN,0.00