Assignment 06

Due: Wednesday, March 11, 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 6 program. Do not create subdirectories in the hw6 directory.

Background: For assignment #4, you wrote a program to figure out the wavelength setting for some device.

Specifications: Now, your assignment is to rewrite the code for hw 4 using functions. We are not going to specify the functions for hw 6 this time around. We leave it up to your good judgement and the principles we have tried to teach you. You will, of course, be graded on how well you break the program into functions. Some very simple pointers: 1) Don't just rename main by doing something like this:

int main()

{

do_stuff();

return 0;

}

This is a useless function. 2) If you have one or two functions, that's not enough. 3) If you have 457 functions, you need to see a psychologist about your infatuation with functions.....that's far too many, so be reasonable.

More specs: The Crime-o-Light 400 has been modernized (so that it works now)1. For the individual wavelength settings described in hw 4, additional information must be supplied by the user. I'll put the modifications in bold for easy viewing. They are as follows:

Wavelength for hair: The wavelength of light emission from the Crime-o-Light 400 that will make hair show up is given by

w = 400 * hair_index,

where hair_index is a value input by the user depending on what color hair sought: 1.2 for blonde, 1.3 for brown, 1.7 for black.

Wavelength for Saliva and hair: The wavelength of light emission that will make hair and saliva come alive is

w = 100 * ( 1 + 1/2 + 1/3 + 1/4 + 1/5 + ... + 1/n) * hair_index, n > 1 hair index is as above

The value of n used will clearly determine the precision of the wavelength value. The larger the value of n, the better the precision. If this option is chosen, then your program must first prompt the user for a value of n that is positive and less than 8, and also prompt for hair_index.

Wavelength for chicken noodle soup and saliva and hair: The wavelength of light emission that will make chicken noodle soup and hair and saliva pop out is

w = 100 * ( 1 + 1/2 + 1/4 + 1/8 + 1/16 + ... + 1/2n) + 2.3(if the soup is homemade), n > 0

Again, the value of n makes the precision and should first be prompted for. Also, you need to ask the user if the soup they are looking for is homemade.

Wavelength for green goo: The wavelength of light emission that will make green goo show up better is dependent on the 'grade' of the goo you are hoping to find, and how tall your believe the little green alien is. You see, green goo (GG) is sort of like motor oil - it comes in different grades/weights dependent on what part of the galaxy the little green alien is from.1 The grades are simply integers 0, 1, .... , 6. GG of grade 0 requires 200 nm, the base wavelength (bw). GG of grade 1 requires the bw plus 43; grade 2 GG needs 17 more than the wavelength for grade 1; grade 3 GG requires the wavelength for grade 2 plus 23; GG of grade 4 needs 77 more than that for grade 3; for grade 5, it is 55 more than for grade 4; and grade 6 GG uses wavelength 35 more than the one for grade 5. Thus, for this option, your code will also have to query the user for the grade of GG they are looking for (an integer from 0 to 6). But also, you must prompt the user for the believe height of the alien: 1 ft or 2ft or 3ft. This value (the height) will multiply the value determined by the above factor.

So, now you have to calculate wavelength based on inputs a bit different than in hw 4. As you can see, you are calculating wavelength in every case. This begs the use of function overloading. But we won't beg. We will demand: you must use function overloading for the computation of wavelength.

When you submit: During the submission,

  1. Choose option 1 and enter info for black hair

  2. Choose option 2 and enter n = -4 when prompted

  3. Choose option 2 and enter n = 4 and blonde hair

  4. Choose option 3 and enter n = 7 and choose for homemade

  5. Choose option 4 and enter grade 3 and 2 ft tall alien

  6. Quit

As usual, if you have any questions, be sure to ask.

1Earlier models of the Crime-o-Light were really nothing more than a cheap incandescent flashlight with a dial from a broken toaster glued onto the side. The dial did nothing.