Lecture notes for the Introduction to Computer Science for non-majors by James Tam Return to the course web page

CPSC 217: Assignment 4 (Worth 6%)

Grading scales

New concepts to be applied for the assignment

  1. Program documentation
  2. Formulas
  3. Decision making
  4. Loops

Determining your lucky number

Some people believe that there are some specific numbers that provide them more luck than other numbers.  We've all heard of people who pick the same lottery numbers every week because they believe that these numbers will provide them with a higher probability of winning.  For this assignment you are to write a program that will ask the user a series of questions and generate for the person their very own "lucky number".1

Your program will ask the user three questions:
  1. The person's age
  2. The person's gender
  3. The type of computer owned by the person

For each question a numerical 'modifier' will be computed each of which will play a role in determining the person's lucky number.

Age
  This value must be a positive integer between 0 and 114 (inclusive).  The age modifier will be determined by finding the remainder of dividing the person's age by 101 (to yield a value between 0 - 100).   For example if the person were 28 years old then the age modifier would be calculated in the following fashion:
 
age modifier = 28 MODULO 101
                     = 28
   
Gender
  The program will prompt the user to enter in a character that represents that person's gender.
   
  Gender Gender modifier  
  Male ('M' or 'm') 200  
  Female ('F' or 'f') 300  
   
Type of computer owned
  Again the program will prompt the person to enter in a single character to indicate what type of computer that he or she owns and the modifier will be calculated as follows:
   
  Computer type Computer modifier  
  Apple ('A' or 'a') 100  
  UNIX ('U' or 'u') 200  
  Windows ('W' or 'w') 300  
  Other type computer ('O' or 'o') 400  
  Multiple computers ('M' or 'm') 500  
  No computer ('N' or 'n') 0  

The program will then sum the modifiers generated from each of the above questions to generate the final computed value ('the lucky sum').  The lucky number that the program displays to the user will depend upon which of the following ranges that the lucky sum falls under.

The lucky sum Lucky number
  200 - 500 7
  501 - 700 13
  701 - 900 888

For example:

Q1: Age = 114, age modifier = 13

Q2: Gender = female, gender modifier = 300

Q3: Computer owned = none, computer modifier = 0

Sum of modifiers from each of the above questions = 13 + 300 + 0 = 313.  Lucky number is...7!

Note: Your program shouldn't display the 'lucky sum' to the user but should instead display only the lucky number (showing two numbers would be somewhat confusing).  The exception is when you are testing your program and trying to determine if your lucky sum is calculated correctly.

Features to be implemented (you will also be graded on other criteria such as coding style and providing program documentation as listed in the marking guide):

Basic features

 
  1. The first time that the program is run it displays an introduction with a brief description.
 
  1. When the user quits the program displays a brief conclusion/signoff message.
 
  1. Prompts the user to enter their age.
 
  1. Reads in the age of the user.
 
  1. Calculates the age modifier.
 
  1. Prompts the user to enter their gender.
 
  1. Reads in the gender of the user.
 
  1. Determines the gender modifier.
 
  1. Prompts the user to enter their computer  type.
 
  1. Reads in the computer type entered by the user.
 
  1. Determines the computer modifier.
 
  1. Calculates the lucky sum.
 
  1. Determines the user's lucky number.
 
  1. Displays the user's lucky number.

Error checking

 
  1. Checks if the user wants to skip the question regarding their age and sets the age to a default value.
   
  1. Determines when the user enters an age below the minimum allowable age (zero) and displays a message indicating that the program will skip the age question.
   
  1. Determines when the user enters an age above the maximum allowable age (114) and displays a message indicating that the program will skip the age question.
   
  1. (In order to get credit for this feature, the program must properly check for one or both of the above conditions). If a value is outside the allowable range then the age is set to the default of 28 (and the age modifier should be calculated in the usual fashion, the age modifier should not simply be set using a simple assignment statement because your program won't work correctly in this case if the formula for determining the age modifier is changed later).
 
  1. Checks if the user wants to skip the question regarding their gender and it sets the gender to a default value.
   
  1. Determines if the user entered a value other than male or female for gender and displays a message indicating that the program will skip the gender question.
   
  1. (In order to get credit for this feature, the program must be able to detect when the user has chosen to skip the gender question). If the user chooses to skip the gender question then the program will set the gender to the default, male and then determine the value for the gender modifier.
 
  1. Checks if the user wants to skip the question about their computer and sets the computer to a default value.
   
  1. Determines if the user entered a value other than one of the listed types and displays a message indicating that the program will skip the computer question.
   
  1. (In order to get credit for this feature, the program must be able to detect when the user has chosen to skip the computer question). If the user chooses to skip the computer question then the program will set the computer type to the default of UNIX and determine the computer modifier based on the computer type.

Other features: improved ease of use

 
  1. Program allows for upper or lower case input for the gender and computer type and to rerun the program.
 
  1. Program can automatically re-run itself. Each time that a calculation has been performed the program will prompt the user if he or she wishes to run the program again or if they want to exit the program.
1 Note: The Lucky Generator program is to be used for entertainment purposes only and neither I nor the University of Calgary provides any express or implicit guarantees that the numbers generated will provide you with greater financial profit or personal gain.

Submission requirements

In addition to having fulfill the generic assignment requirements, the requirements specific to this assignment include:

 
  1. Include a README file in your submission:  For this assignment you need to include a file called 'README' which includes your contact information: your name, university identification number and UNIX login name so that your marker knows whose assignment that he or she is marking. 

 
  1. The programming assignments require a two part submission: a) A paper submission of your README file and Python program into the assignment drop boxes (second floor Math Sciences) b) An electronic submission (again of your README file and your Python program) as an email attachment (don't cut and paste it into the email body!) to the following people (failing to include everyone listed below may result in your assignment not being marked for credit so before submitting your assignment double check!) Make sure that the subject line of the email contains the exact text (don't add or delete anything to it or you will lose marks): CPSC 217 Assignment X.

X = The appropriate assignment number (e.g., for Assignment 3 the subject would be titled "CPSC 217 Assignment 3")

 
  1. The course instructor at the following email address: tamj@cpsc.ucalgary.ca
 
  1. Your tutorial instructor, the email addresses for the TA's can be found on the main course web page.
 
  1. The TA coordinating the marking of assignments: amaobied@ucalgary.ca (if you are in Ahmed's tutorial you don't have to send your assignment to him twice, other students must send their assignment both to their TA and to Ahmed).
 
  1. Yourself. Sending the assignment to yourself provides one last "double check" that you submitted your assignment properly (e.g., you sent it to all the right people, you attached all the important files to the submission etc.) When you receive the submitted assignment you can check one last time to make sure that you fulfilled all the requirements. If you forgot something then you can resend your assignment with a note to mark only the latest submission (but try not to resubmit your assignment too many times please).
 
  1. 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.
To help make sure that you haven't missed anything here is a checklist of items to be used in marking.
   

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