30 points
In your cps006 directory, you should create an assign3 directory to work in. You'll then copy files into this directory to help you get started. That is, type the following unix commands from your account after you login (don't forget the trailing dot on the last line).
cd cps006 mkdir assign3 cd assign3 cp ~ola/cps006/assign3/* .If you did these commands correctly, typing pwd should show that you are in your assign3 directory, and typing ls should show the files Makefile and simpquiz.cpp.
Copy the file using the Unix command cp to a new file named mathquiz.cpp
cp simpquiz.cpp mathquiz.cppNow modify the program in mathquiz.cpp to ask easy, medium, and hard questions, where these kinds of questions are defined as:
score = (#easy questions correct) + (#medium questions correct)*2 + (#hard questions correct)*3 - (#of incorrect answers)*2So if a user has 3 easy questions correct, 2 medium questions correct, and 1 hard question correct, with 3 questions incorrect, the score is
3 + 2*2 + 1*3 - 3*2 = 4(it's possible to get a negative score).
Whenever the running score is less than three, an easy question is asked. If the running score is 3--6 a medium question is asked. If the running score is more than 6 a hard question is asked.
After ten questions are asked the final running score should be displayed as should the number of each type of question the user gets correct.
Each trait is governed by a sinusoidal curve with a periodicity that depends on the trait, so that a physical cycle is 23 days long, an emotional cycle is 28 days long and an intellectual cycle is 33 days long. All cycles start on the day you're born.
Since the emotional cycle is 28 days long, your emotional peak occurs on day 7 of your life (and then on day 28 + 7, 56 + 7, etc.). Your emotional level is at zero on day 14 (and on day 28). Your emotional leval is at its lowest on day 21 (and on day 28 + 21, 56 + 21, etc.).
Because the curve is sinusoidal, it's as though it behaves like the function y = sin( (2.0*PI/28) * x), since the period of this function is 28. Here x could be the number of days a person has been alive, y provides a value between -1 and 1 that can be interpreted as the "level" of a biorhythm cycle (1 is max, 0 is a potential critical crossing). Changing 28 to 33 or 23 provides a different function for each biorhythmic trait.
If all three traits cross the x-axis on the same day, a critical day occurs.
For example, assume the program below is run on September 27, 1999 and uses a birth date of the same day to illustrate the cycles.
prompt> bio enter birth date, month day year: 9 27 1999 physical high: October 3 1999 physical low: October 14 1999 emotional high: October 4 1999 emotional low: October 18 1999 intellectual high: October 5 1999 intellectual low: October 22 1999Low and high days are rounded off so that the physical high which should occur on day 23/4 = 5.75 is rounded to day six after birth. The physical zero is on day 23/2 = 11.5 which is rounded up (all .5 values are rounded up). The physical low is day 23*0.75 = 17.25 = day 17.
To plot using asterisks and other ASCII symbols you'll need to use the value of the sin function that governs the intellectual cycle: y = sin( (2.0*PI/33) * x) and scale it by half the width of the screen, for example. In the plot below the maximum value used is 25 "units".
Each line of output corresponds to a date. Print spaces before (or after) the asterisk and print either a | for the x-axis or a Date/day for every other day (see the output below.)
prompt> biograph enter birth month day year: 9 27 1999 Birthday: September 27 1999 * | * 29 * | * 1 * | * 3 * | * 5 * | * 7 * | * 9 * | * 11 * | * 13 * * | * 15 * | * 17 * | * 19 * | * 21 * | * 23 * | * 25 * | * 27 * | * 29 * | 31 * 1 * | * 3 * | * 5 * | * 7 * | * 9 * | *
submit_cps006 assign3 mathquiz.cpp bio.cpp biograph.cpp READMEIn your README include how long you worked on the programs, your impressions of the program and comments you have about the assignment, and list of people with whom you collaborated.
If you did the extra credit, include critical.cpp on the submit line above. The extra credit must be done by the same due date as the assignment.