Assignment 03

Due: Friday, Sept. 16, 2016 at noon 100 pts

For this assignment, you will submit a single C++ compilable file containing a program written in C++. Remember, to submit a file for this course electronically, from the directory in which the file resides type in at the UNIX prompt

the command: cssubmit 1570 section_letter assignment_number. Be sure that only the file you want to submit is in that directory - make a directory for every assignment! The submit system will deliver every .cpp file in the current directory to me. Name your file a meaningful name and give it a .cpp extension since you will be compiling it. Also, make sure that you compile and run your program using the GNU (g++) compiler before submitting to make sure that it will work for the submit script.Background: Lisa, our environmental hero, has once again decided to try to help the conscientiousness of the Springfield general population by bringing to light the plight of starving homeless and endangered animals. You see, there are many starving homeless, endangered animals that Lisa thinks she has to help. There really aren't. But she's going to hold a benefit event/concert that will engage and inspire and motivate the town's people by having them personally participate. Wishing to involve her beloved saxophone, her idea for a "Snax-A-Thon" will help to raise awareness by having individuals provide inspiration that will determine which notes on her saxophone she will play! Cooool, eh? The notes she plays will then determine how much each of the animals will get fed that day. But, she can't play and compose at the same time; she needs a computer program (written ONLY in C++...naturally) to compose her sad, dissonant, jazzy, meandering composition - you know, music no one really wants to listen to.Specifications: Your code should, of course, greet the user - presumed to be Lisa, but she may pass this program on to future generations. Then, it should prompt for and read in from the user a positive integer between 10 and 100, inclusive, called the "inspiration number". (Lisa thinks any input value below 10 is just too Ralph Wiggumian and any value larger than 100 is too John Coltranian.) Your program should

The amount of food each animal gets is simply a tally of the number of times a note is played. Thus, say, if A is played 16 times, then the appropriate animal is fed 16 snax. The animals are:

Bb bleep

C++ do-wah

D- ding

E# honk

Fb wapp

H DOH!

Note: be sure to put a space in the output between notes played.

A 0

Bb 1 (that's a B-flat)

C++ 2 (sorry, no C# in this course!)

D- 3

E# 4 (Lisa is also an anarchist)

Fb 5

H 6 (a note Homer forced on Lisa)

A 7

Bb 8

C++ 9

. .

. .

. .

etc

You see the pattern? Yes.

The sounds of the notes are:

note sound

A wah

  1. ensure the input is valid. With a single, initial user input inspiration number, your code will accomplish several tasks:Compute the note to be played

  2. Output the sound of the note

  3. Determine how much each animal gets to eat (hence, Snax-A-Thon....get it? .... ok, it's lame)

  4. Calculate the successor to the current inspiration number, which will determine the next note played

These three steps will be repeated until the current inspiration number is 1, signalling the end of the "composition".....and our tolerance for jazz.

Details: How are notes to be played determined? Lisa's mathematical prowess inspires her to map the seven (7) notes she is able to play to the non-negative integers thusly:

note value

note animal A El Chupacabra Bb BuckToothedSlug

C++ freaky fish

D- 3-legged snakes

E# trash bears

Fb Hans

H Cletus

After the output of the note sound and the tallying of snax, the inspiration number will change the the next note will be determined, output, tallied, etc until 1 is reached. The computation of the next inspiration number is as follows:

  • if the current inspiration number is even, the successor is the current divided by 2

  • otherwise, the successor is 1 plus 3 times the current (3*current + 1)

As an example, suppose the user inputs 11. The program should determine the first note "played" corresponds to a value of 4 or E# and so "honk" is output, trash bears get one more snack, and the next inspiration value is 34. Since this is not (usually) 1, the program would continue by computing the next note to correspond to the value 6 or H and so "DOH!" is output, Cletus gets one more snack, and the next inspiration value is 17. Since this is not 1, the program would continue by computing the next note to correspond to the value 3 or D- and so "ding" is output, 3-legged snakes gets one more snack, and the next inspiration value is 52. Etc.

After the program outputs the "tune", it should output the number of snax each animal gets for that tune. The program should also output a termination message and then terminate. More than one jazzy tune generated with this program could possibly cause brain damage, and we don't want that.

Note: You are not to use the switch/case statement in this program.

When you submit: the submit script will (attempt to) compile and execute your program in the process. This means that you will be the "user" of the program for that few minutes. Now, in order that the grader isn't driven crazy by a multitude of inputs/outputs, you will ALL input the same values so that he has uniform output to grade. As the user, input

  • initial inspiration number 9, which had better generate an appropriate error message.

  • initial inspiration number 101, which had better generate an appropriate error message.

  • an initial inspiration number 56. This will generate a catchy little tune you all can learn to love.

As always, if you have any questions about this assignment or our mental state, just ask your instructor.