CO311: Introduction to Modern Programming II

Lab Practical #7: March 20, 2000

Please read the entire problem before jumping into the code!

Write a program that will read data from a file that is specified by the user. The data will be organized as follows:

There will be exactly 5 records in the file, one record per line. For example:

328712 Hammer 15.75

Each record consists of three components:

After reading all 5 records into your program, print to the screen a “receipt” showing the item, it’s part number in parentheses, and it’s cost. Example input:

328712 Hammer 15.75
33274 Pliers 8.95
1000456 Bolt-cutter 38.99
43234 Screwdriver 8.95
9833321 Fencing 75.00

Example output:

Hammer (328712)  $15.75
Pliers (33274)  $8.95
Bolt-cutter (1000456)  $38.99
Screwdriver (43234)  $8.95
Fencing (9833321)  $75.00

Use good programming methods, including separate functions where appropriate. A copy of the sample file (receipt.txt) can be found in the COMMON area of the FTP site under practicals/p7.

Submit the finished CPP file to the FTP site in its own folder called P7.