Lecture notes for the Introduction to Computer Science I by James Tam Return to the course web page

CPSC 231: Assignment 3

Due: November 4 by 4 PM

New Concepts to be applied for the assignment

Introduction

Numerology is based on the belief that everything consists of and is affected by numbers. Your date of birth, for instance, can be translated to a "life path number" which is then supposed to provide information about "...your true nature, your desires and your destiny."1

Assignment

You are to write a program that will prompt the user for his/her birth date (day, month, year). This information is to be entered in numeric form within the following ranges: 1<=day<=31, 1<=month<=12, 0<=year<=9999. If a value outside of these ranges is entered then the program will display an message that specifies what the caused the error/how to prevent it from happening again e.g. Birth month must be from 1 - 12. Also the program should check that the day/month combination is valid:

Months with 31 days January, March, May, July, August, October, December
Months with 29 days February
Months with 30 days April, June, September, November

If the day of birth exceeds the maximum number of days for a particular month then the program should display an appropriate error message and re-prompt for a valid combination. Your program can ignore the effect of leap year by making the assumption shown above (February has 29 days).

Once a valid date of birth has been entered then following formula is used to convert it all to the life path number.

Step 1: Convert each of the birth day, birth month and birth year to a single digit number.

 

Values already consisting of a single digit need not be converted
e.g., birth month = 1

 

Values consisting of more than one digit are broken into individual digits and added together
e.g., birth month = 11 is split into 1 + 1 = 2

 

If the sum consists of multiple digits then the process of breaking a number down into individual digits and adding them together is repeated until a single digit number is derived.
e.g., birth year = 1977 becomes 1 + 9 + 7 + 7 = 24
24 is split into 2 + 4 = 6 (year is now converted to a single digit, no more converting needed)

Step 2: Add the three single digits.

  e.g., Birth date: 11/17/1972
Reduced to single digits yields: 2, 8, 1 (previous step)
Adding these digits = 2 + 8 + 1 = 11 (this step)

Step 3: Reduce this sum to single digit to yield the life path number.

  e.g. 11 = 1+ 1 = 2

The program should then display the life path number to the user. It's not required that the program display the specific meaning or interpretations behind a number. (If you are interested in the additional information then you can go the website referenced).

Although the new concepts introduced are loops and branching, the concepts from previous assignments should also be applied in this assignment such as following good programming conventions, documentation, breaking the program down into functions etc.

Reminders

Reference (provided to credit the source of information used to design this assignment and it is not mandatory that study the material for the assignment)

  1. http://aboutnumerology.com/lifepathmeanings