Assignment 12
Due Tuesday, November 8 at 3:20pm on Catalyst


Assignment 12.1: What's Your Sign? (10 pts)
  • For this assignment, let's write an astrology program.
  • Welcome the user (see sample output below)
  • Prompt the user to enter a numerical value (1-12) for the month of his/her birth (see sample output)
  • Prompt the user to enter a numerical value (1-31) for the day of his/her birth (see sample output)
  • Then, determine the user's sign based on their input.
        Aries                March 21-April 19
        Taurus             April 20-May 20
        Gemini            May 21 - June 21
        Cancer            June 22 - July 22
        Leo                  July 23 - August 22
        Virgo                August 23 - September 22
        Libra                September 23 - October 22
        Scorpio            October 23 - November 21
        Sagittarius       November 22 - December 21
        Capricorn        December 22 - January 19
        Aquarius         January 20 - February 18
        Pisces            February 19 - March 20
  • Your program must include a while loop to allow the user to repeat the calculation for another date of birth.
  • Expect to need to use if, else if and else statements.
  • Expect to use logical operators (&&, ||).
  • Submit your source code to Catalyst when finished

Your sample output must be identical to mine:




Assignment 12.2: Humpty Dumpty Again (10 pts)
  • Open up humpty.cpp from assignment 11.
  • Using a for loop: Write a program that prints the numbers from 1 to 150, with each number printed on its own line.
  • For multiples of five print "Humpty" instead of the number
  • For the multiples of seven print "Dumpty" instead of the number.
  • For numbers which are multiples of both five and seven print "Had a Great Fall".
  • You must use a for loop for full credit.
  • When you are finished, and your output looks like mine, upload your assignment to Catalyst.
Your Output Should Look Like the Following. Note that some values have been omitted for brevity.

1
2
3
4
Humpty
6
Dumpty
8
9
Humpty
11
12
13
Dumpty
Humpty
...
34
Had a Great Fall
36
...
149
Humpty


Assignment 12.3: i and j (10 pts)
  • Open up CodeBlocks and create a new C++ file called ij.cpp.
  • In this assignment, we are going to write another program that uses a for loop. 
  • Within the loop, make the variable i go from -5 to 5, counting by 0.5. (This means that i can't be an int.)
  • Inside the body of the loop, set another variable j to be the current value of i raised to the third power
  • For output, you will need to display the current values of both i and j in a chart, as shown below.
  • You will need to use tab, fixed and setprecision(n) and the pow(base,exp) function here. (What libraries do you need?)
  • When you are finished, upload your source code to Catalyst.
Your Output Should Look Like the Following. Note that some values have been omitted for brevity.

i          j

-5.0       -125.0

-4.5       -91.1

-4.0       -64.0

...

4.0        64.0

4.5        91.1

5.0        125.0