CS3304 Data and Information Structures

Project 3 The Use of STL

This project is an exercise of the use of STL containers and algorithms, studied in Chapter 9 and 10.

Requirements: The use of STL containers and algorithms is required to do this project. Use C++ to write your program and Visual Studio.net to test your program before hand-in.

The Problem: The Rinky Dooflingy Company manufactures different kinds of dooflingies, each identified by a product number. Write a program that reads product numbers and prices, and stores these values in a container. The program then sorts the products so the product numbers are in ascending order, print a table displaying the product number and the price of each item. Then, the program sorts the products so the product prices are in ascending order, print a table displaying the product number and the price of each item.

Input: The input of the program must be saved in a text file. Input file should contain a list of product numbers and prices, one product per line, with the product number followed by the price. Product numbers are integers and prices floats. Product numbers are in random order in the file. For example,

12 567.00

3 34.00

45 123.00

23 5.78

...

Your program should read all product information contained in the file. Create input file(s) and include them in the disk to hand in.

Output: The program should echo print to the screen the product information as it reads input from the file, presented in a table. Sorted product information should then be printed out in two tables, one representing the result of sorting by product numbers and the other the result of sorting by product prices.

Suggestion: Define a Product class with two Boolean comparison operations, one to compare products using product numbers and the other using product prices, so that standard algorithms can be used on the container of Product objects.

Hand-in: Hand in a print out of your source code and a disk containing your source code and input file(s) on the due day.