Introduction to Computer Science II by James Tam | Return to the course web page |
Some people believe that there are some specific numbers that provide them more luck than other numbers. We all have 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 For this assignment you are to submit a program with a single class "Driver.java" that implements the capabilities listed below.
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 (28 divides into 101 zero times leaving a remainder of 28, 102 would divide into 101 once with a remainder of 1). | |||
|
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 used | ||
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 and it will either add or subtract 100 from this sum (there's an equal chance for each) 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 value falls under.
The lucky sum | Lucky number | |||
100 | - | 399 | 7 | |
400 | - | 699 | 13 | |
700 | - | 1000 | 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.
Assume that when the program is run it randomly determines that it should subtract 100 from this amount so the resulting final computed value equals 213 (313 - 100) so that the program would display '7' as the lucky number. (If the program randomly determined that it should add 100 to the sum then the final computed value would equal 413 (313 + 100) and the program would display '13' as the lucky number). 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. In this case you could set up a debugging mode that would show both values but only when explicitly requested by the user.
These assignments implement all of the required functionality listed above and also follow good coding style and be fully documented as described in the style guidelines.
Marking for assignments that are missing or incorrectly implement the above features:
The minimum grade for a program that compiles (and involved a considerable time and effort to write) is a 'D' regardless of the number of features that may be missing or incorrect.
Implementing all the features below correctly can allow you the potential to receive a grade of 'A' (again style and documentation standards must still be met).
Feature 1, the program performs some rudimentary error checking: These assignments fulfill all of the requirements for a 'C' level submission (or higher) and performs some basic error checking. If an invalid value is entered the program will generate an appropriate error message and a default value will be used by the program.
|
||
|
||
|
||
|
||
If all of these requirements are fulfilled then you can receive an extra two letter steps. If the feature listed in the second or third point is missed then you can receive one letter step. If more than one of these points is missed then you won't receive credit for this feature (you've missed to much and your error checking really doesn't do anything). If the features listed in the latter two points are correctly implemented but one of the checks for the upper or lower bound was incorrect then you can receive one extra letter step. | ||
|
||
|
Feature 2, the program is able to re-run itself: These assignments fulfill all of the requirements for 'C' level submission (or higher) and 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. (Worth 2 letter steps).
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. |
2 | What does and doesn't constitute a sufficient amount of time and effort? It's a judgment call on the part of your marker. More often than not if you put in a reasonable amount of effort into your assignment and for some reason you just couldn't get it to work then you will receive credit for your work. An example of when you wouldn't receive credit is when you simply handed someone else's work. This latter case assumes that you properly cited the other person's work, if you didn't cite your source and tried to claim that it was your own work then it would be an example of academic misconduct (cheating). |