Assignment 07

Due: Friday, March 20, 2015 at noon 100 pts

Instructions: You know how to submit; do it in the usual way. However, this time you will submit multiple files for this programming project. The cssubmit script will work as usual, picking up all .cpp and .h files in the current directory. So, make sure you have created a separate directory for your hw 7 program. Do not create subdirectories in the hw7 directory. In fact, don't do that in any of our assignments!

Background: As some of you might already know, guns/bullets have something akin to fingerprints. Every gun produced leaves a "fingerprint" on every bullet fired from its barrel. Variations in rifling (grooves cut into the inside of a gun barrel), tiny little aberrations in the metal sides of the barrel, differences in the chambering mechanisms....all make different marks on the bullets that are used in that gun. So, a bullet can then be matched to a gun since every bullet fired from one gun will have the very same markings on it. So what forensics people do is, finding a bullet from a crime scene, they can identify the gun that fired it (and possibly the perp) by matching the markings on the bullet to the markings on bullets found in a database of bullets that are, presumably, matched to known guns. Match the bullets, you match the gun! Match the gun, you match the "finger man" (perpetrator). Get it....yeah, I knew you would. This program will emulate that process. But, of course, in a funny sort of way.

Specifications: Your program is going to loop input/outputs until the user doesn't want to use its functionality any more. You will prompt the user to input information about a bullet, try to match that bullet with bullets (hence, guns) in a "database", and then output a message telling them you found a match and what the info is, or that you have no match and they're just out of luck. This will be looped as you will ask again for input, etc.

Details: Now, since you nor I have a database of bullets' fingerprints, your program will first make that database using random values. Yes, I know this sounds absolutely insane - and I don't refute that assertion! - but what can you do...no data? make some up! In order to do this, you must know the fingerprint information of a bullet. You will use a struct to hold that information. Your bullet fingerprint info struct will contain members for the following:

  • the caliber of the bullet. Use a float for this value.

  • the number of lands/grooves on that bullet, hence in that gun's barrel. Use a short for this.

  • the width of a land. Use a float.

  • the width of a groove Use a float.

  • the bullet has chambering marks. Use a bool here.

  • the name of the last known owner of the gun that produced this bullet. Use a string.

And so what are these things you ask? The caliber of the bullet is the diameter of the barrel and bullet. For this assignment, we will restrict ourselves to 22 cal, 38 cal, and 50 cal. (A caliber is a is a way of saying a hundredth of an inch. Thus, 22 cal is .22 inch. Likewise, a 38 cal is .38 inch.) So, the choice of values for our bullets' calibers is 0.22, 0.38, and 0.50. I know this is rather limited, but you really don't want me to expand the assignment to adequately reflect reality! The lands and grooves are the ridges and valleys on the bullet corresponding to the valleys and ridges of the grooved barrel. We will assume that all guns are made with either 5, 6, or 7 lands/grooves. (note: there are always the same number of lands as grooves, so only one variable is needed here.) The width of a land can vary from 0.025 to 0.030, inclusive. Likewise for grooves.

  1. .38 cal with 6 lands/grooves with landwidth .025 and groovewidth .03 and has chambering marks

  2. .22 cal with 7 lands/grooves with landwidth .027 and groovewidth .027 and does not have chambering marks

  3. quit

And, as usual, if you have any questions about his assignment, don't hesitate to ask questions.

1In order to sort the information, you will need to code a sorting algorithm. I suggest writing the code for bubble sort. Now, you can easily find this sort somewhere online and copy it. But don't! You won't learn a thing doing that. Code it yourself; it's only a few lines of code.

Thus, you are to start your program by declaring an array of 25 bullets (structs). Then, your code will walk down that array randomly assigning values (in the ranges listed above) for all those member variables for each bullet. For the name of the owner, prompt the user. This means that you will have to come up with 25 names to input at run-time! Be prepared. Make the names fun. But REMEMBER: cin>>string_var; will only read to the first whitespace. So, when typing in names, don't input names with spaces in them. If you have to, use the underscore to connect parts of names (e.g. Mr_Bad). This array is your "database".

After establishing your database (array), you are to output the entire array in an easy to read format. Here's an example if you can't think of anything:

(.22, 8, .025, .028, no marks) (.22, 8, .026, .029, marks) (etc....) or one per line, but that uses up more paper. No name output here.

This is to be followed by the output of the entire array sorted1 by caliber (only). That output is to be followed by the output of the bullet in the array that is a .38 cal with the largest groove width. (If multiple bullets, pick the first.)

After the above initial output, your code will input bullet info from the user to possibly find a match, and repeat that until the user has no more input. Note: There can be more than one match, so just pick the first match. When you output the bullet info if a match is found, be sure to output (in some funny way) who the possible perp is. It could be something like

A match! This .38 bullet with 5 grooves ... and marks belongs to the no good scoundrel and thievin' Roscoe.

Also, gun/bullet forensics experts will allow a match if the width of lands and grooves is within a 0.001 tolerance. So, your code for finding a match should implement that allowance.

Special Notes:

  • When you develop your code, you will (probably) be running it over and over. Well, you won't want to input names over and over again. So, I suggest you comment out your cin>>name; line and replace it with name = "bob"; temporarily. Then in your final test and submission, change back.

  • You are allowed to have fun with this. Here's a suggestion. Write code that will vary the output message. It's not hard to do; use your imagination and make it goofy. Have several output messages for a found match and have your code pick from them at random.

When you submit: Enter bullet info as follows: