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

CPSC 231: Assignment 2

Due: Friday October 19 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) 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 28 days (ignore leap year) 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.

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 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*). You can find sample program outputs in the course directory under /home/231/assignments/assignment2/outputs.txt or via this [web link].

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 etc.

Submitting your work:

  1. Assignments (source code/'dot-py' files) must be electronically submitted according to [the assignment submission requirements].
  2. As a reminder, you are not allowed to work in groups for this class. Copying the work of another student will be regarded as academic misconduct (cheating). For additional details about what is and is not okay for this class please refer to the following [link].
  3. Before you submit your assignment to help make sure that you haven't missed anything here is a [checklist] of items to be used in marking.

External libraries that can be used

  1. Libraries that allow for text-based (console) input and output.

Reference

  1. http://aboutnumerology.com/lifepathmeanings

* The information does not necessary reflect the opinions of the course instructor or the University of Calgary and only reflect the opinions of the website's author or authors.