Lecture notes for the Introduction to Computer Science I by James Tam | Return to the course web page |
Score | Grade |
62 - 64 | A |
58 - 61 | A- |
54 - 57 | B+ |
50 - 53 | B |
45 - 49 | B- |
41 - 44 | C+ |
37 - 40 | C |
33 - 36 | C- |
28 - 32 | D+ |
21 - 27 | D |
11 - 20 | D- |
0 - 10 | F |
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: |
|
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.
Basic features |
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
Error checking |
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
Other features: improved ease of use |
||
|
||
|
To help make sure that you haven't missed anything here is a checklist of items to be used in marking.
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. |