ESc 014

Assignment 3 -- Police Blotter
Due: Tuesday, April 23, 2002

Objectives

Your Mission

As a public service, the local police department keeps a file of city residents who have marked their belongings with a unique 4-digit ID code (an integer). When the police recover a missing item, they would like to use a computer program to match the item with its original owner via its ID code. Your assignment is to write a program to do just that.

The Input

Your program will use two external data files for input, and they can be downloaded from the Course Materials section of BlackBoard. You are not allowed to alter the input files in any way. The files are described below.
  1. registered.txt is the file containing information about the people who have registered their items with the police. Each line of the file contains 1 record telling the 4-digit ID code of the item, the owner's first name, the owner's last name, and the owner's phone number. For example, a line such as
    1900 John Smith 555-4321
    
    means that John Smith with phone number 555-4321 has registered an item with the unique ID 1900. The last line of this file will be the integer "0" (without the quotes) that you can use as a sentinel to tell you when you've reached the end of the file. Note that this file is sorted in order of increasing ID codes.

  2. recovered.txt contains information about the recovered items. Each line of the file pertains to one item telling its 4-digit ID code and a one-word description of the item. For example, a line such as
    1408 refrigerator
    
    means that the police recovered a refrigerator whose unique ID is 1408. This file also has 0 as its last line that you can use as a sentinel.

The Details

Here's how your program will work.
  1. First, use an array of structs to store the registration information contained in the registered.txt file. Each struct will contain information on a single item (its ID, owner's first name, last name, and phone number). You may assume that there will be no more than 100 items in the registered.txt file.
  2. Process the recovered.txt file by doing the following with each line of the file:
When you have finished processing the recovered.txt file, you should have an external output file containing a well-formatted report that the police can use to reunite the orphaned items with their long-lost owners. The report should look something like this:
ID code    Owner         Phone     Description
----------------------------------------------
 1900      John Smith    555-4321  television
 1177      NO MATCH      N/A       car
 1408      NO MATCH      N/A       refrigerator
 1046      Sally Chan    484-9843  violin
Your report doesn't need to look exactly like this, but it should be formatted neatly into columns with headings for each column.

Remember to use functions to break up this problem into smaller pieces. Some of the functions you might use here are:

You may use other functions as well.

Grading

This assignment is worth 50 points, divided as follows:

Remember to turn in both a paper and an electronic copy of your project on BlackBoard. Name your file with your FULL NAME along with the assignment number (e.g. chrisfernandes_hw3.cpp)

Having trouble? Don't wait until the last minute! Come see me and get your $80 worth.

Administrative statement

Programming assignments are individual projects. I encourage you to talk to others about the general nature of the project and ideas about how to pursue it. However, the technical work, the writing, and the inspiration behind these must be substantially your own. If any person besides you contributes in any way to the project, you must credit their work on your homework. Similarly, if you include information that you have gleaned from other published sources, you must cite them as references. Looking at, and/or copying, other people's programs or written work is inappropriate, and will be considered cheating.
Return to Assignment Index