Assignment 07

!NEUROTIC FLYING PENGUIN MISSILES

Due: Friday, Oct. 20, 2016 at noon 100 points

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: So, our hero Hans has learned a lot from his ownership and subsequent mismanagement of a penguin. So now, he wishes to begin a very real1 controlled breeding program of penguins2 to produce a super-race of flying penguins3 that can be used as missiles4 by the military5. Penguin eugenics....yes! Well, there's no limit to what Hans can do. And this is where computing comes into the picture. You are again going to write a program to simulate what will happen. You will have a set of penguins, each described by a set of attributes, both physical and behavioral, which your code will organize and process. The outcome might be very scary.

Specifications: Your code for this project will declare an array of 50 penguins.

Next, you will create another array. This third array has 4 elements, each of which is an array of integers (an array or arrays). Each of the member arrays of ints is the same size as your data set (50) because it's possible (though very very unlikely) they could hold as many data as the data set size. Each of these 4 arrays represent categories of the data. The first of the member arrays is the indexes of the data set that are penguins with neurosis levels in the interval [1.00, 4.00); the second for neurosis levels in [4.00, 6.00); the third for the interval [6.00, 8.00), and the last for the interval [8.00, 10.00]. NOTE: [a, b) means include a, but upto and not b.....inclusive of lower end point and exclusive of upper end point. So, now you will fill those arrays appropriately with the indexes of the penguins taken from the data set.

After this, you are to identify the top contenders of the data set that will be used for breeding experiments. How? Well, you are going to consider the top 10% of the data set with the longest wingspan (using the second array above) to see if any of them are in the lowest category of the third array (those with the least neurotic behavior). You will identify them if they exist and output their information; and if there are none, then output a big message stating that "PENGUIN EUGENICS WILL FAIL: THE WORLD IS SAFE!" Now, if there are more than one super-breeder penguins from this experiment, you are to "compute" and output the penguin which will be the result of breeding these super-breeders6. That penguin will be identified as ... um ... SUPER PENGUIN....and he/she will have:

  • Jerry for a name

  • a wingspan that is 1.7 times the average wingspan of the breeders

  • a weight that is 60% of the average weight of the breeders

  • a neurosis level that is the minimum of the breeders

  • a extroversion value that is random (with in the standard limits)

The output: We need to specify the output of this program pretty tightly so we can see that it works given the random nature of the penguins. We want the output to follow this prescription and order:

  1. the entire data set of penguins in the order they were created

  2. the half of the data set with the longest wingspans sorted by decreasing wingspan

  3. the penguins with the greatest neurotic behavior

  4. a list of super-penguin breeders as identified by the above methodology --- or --- "PENGUIN EUGENICS WILL FAIL: THE WORLD IS SAFE!" if there are none

  5. SUPER PENGUIN

Any output of a penguin should be one penguin per line and like this as an example: Bob wingspan: 54 wt: 5 neurosis: 5.56 extroversion: -.54 Put a tab character in the output between each field (name, wingspan, weight, neurosis, extroversion) for readability. Also use headings for the different categories of output above.

Of course, you are to use functions and multiple files for this programming project. And, of course, use all the usual "good programming practices" you have been taught.

Wait, c++ doesn't have a data type called penguins. Thus, you first need to create a new type called penguin. A penguin has three attributes: a name, a personality, and a physique (two more new c++ types you are required to create). Physique is determined by two integers: weight (4 lbs to 20 lbs, inclusive) and wingspan (4 inches to 24 inches, inclusive). Personality is determined by two floats, one for neuroticism (ranging from 1.00 to 10.00, inclusive), and one for extroversion (ranging from -5.00 to +5.00, inclusive), both keeping 2 decimal places. Now you can declare an array of penguins. But once you do so without any initialization, you end up with an array of very weird penguins indeed! Some will have negative wingspans, etc. So, you will need to give to each penguin in your array of penguins traits that are random but fit the specs given above. This array will remain unchanged. Let's call it the "data set". Assigning the random values for personality and physique is simple and needs no explanation. For names, you can do this any way you wish, but here's a good idea. Create a constant array of 50 strings with initial values that are names you choose. Then, when assigning a penguin a name, you just index into that array. I'd recommend choosing names that aren't too long. This is because you're going to be yelling at these beasts all day long and a long name is harder on the vocal chords.5

Now that you have your flock of penguins, you are to create another array of integers representing the index of the penguins; so it will be sized 50 also. You will sort the penguin data by increasing wingspan storing the information in this second array. That is, when you are done with this task, the first element of this second array will contain the index of the penguin in your data set having the shortest wingspan; the second element is the index of the penguin in your data set with the second shortest wingspan, etc. So, you see, you are storing indexes, not wingspans and not penguins.

1not really very real.

2really very not real.

3very really not real.

4real? Not really very.

5I can't believe this nonsense.

6Don't ask me how this happens. I'm a computer scientist, not a biologist. Google "biology of the super-secret super-penguin breeding program for neurotic penguin missiles" and see what you get.

Special Note: (Absolutely) no penguins were harmed in the production of this assignment. Absolutely!

When you submit: There is no input (unless you have chosen to read in penguin names from the user, which is a really bad idea), so just submit. Seed your random number generator with time(NULL). Then cross your fingers and pray that the world is safe from penguins and Dr. Moleman!

And as usual, ask your instructor if you have any questions.