Lecture notes for the Introduction to Computer Science I by James Tam | Return to the course web page |
Score | Grade |
59 - 60 | A |
57 - 58 | A- |
54 - 56 | B+ |
51 - 53 | B |
47 - 50 | B- |
43 - 46 | C+ |
39 - 42 | C |
33 - 38 | C- |
27 - 32 | D+ |
21 - 26 | D |
11 - 20 | D- |
0 - 10 | F |
Module | Type | Input / parameters | Function return value | Description | Marks for implementing the module |
main | procedure | NA | NA | The starting point of execution for the program | NA - it will be given to you to help you start your program. |
initialize | procedure | runAnswer (char) age (integer): ageModifier (integer): gender (char): genderModifier (integer): computer (char): computerModifier (integer): luckySum (integer): luckyNumber (integer) |
NA | Set variables to default starting values. If you have additional variables declared that need to be initialized then you can also pass them to this procedure. | NA - you need to implement this module as part of good programming practice. |
introduction | procedure | none | NA | Describe how the program works. The procedure runs once as the program first runs. | 1 mark |
conclusion | procedure | none | NA | Display a signoff message so that the user knows that the program has ended. | 1 mark |
askAge | procedure | age (integer) | NA | Prompts the user to enter their age (1 mark), reads in the value entered by the user (1 mark). If after calling function 'skipAgeQuestion' its determined that the user wants to skip this question this module sets the age to the default (1 mark) | 3 marks |
skipAgeQuestion | function | age (integer) | Boolean | If the user enters an age that is outside the range for a normal allowable age then this function has determined that the user wants to skip the age question and it will return true. If the user enters an age that is within the allowable age then this function has determined that the user does not want to skip the age question and it will return false. | 4 marks |
determineAgeModifer | function | age (integer) | ageModifier (integer) | Based on the age entered by the user, this procedure will determine what the age modifier will be and return this value to its caller (2 marks). | 2 marks |
askGender | procedure | gender (char) | NA | Prompts the user to enter their gender (1 marks), reads in the value entered by the user (1 mark). If after calling function 'skipGenderQuestion' its determined that the user wants to skip this question this module sets the gender to the default (1 mark) | 3 marks |
skipGenderQuestion | function | gender (char) | Boolean | If the user enters a gender other than male or female then this function has determined that the user wants to skip the gender question and it will return true. If the user enters male or female then this function has determined that the user does not want to skip the gender question and it will return false. | 2 marks |
determineGenderModifier | function | gender (char) | genderModifier (integer) | Based on the gender entered by the user, this procedure will determine what the gender modifier will be and return this value to its caller (2 marks). | 2 marks |
askComputer | procedure | computer (char) | NA | Prompts the user to enter their computer type (1 marks), reads in the value entered by the user (1 mark). If after calling function 'skipComputerQuestion' its determined that the user wants to skip this question this module sets the computer type to the default (1 mark) | 3 marks |
skipComputerQuestion | function | computer (char) | Boolean | If the user enters a computer type that is not one of the allowable types then this function has determined that the user wants to skip the computer question and it will return true. If the user does enter one of the allowable computer types then this function has determined that the user does not want to skip the computer question and it will return false. | 4 marks |
determineComputerModifier | function | computer (char) | computerModifer (integer) | Based on the computer type entered by the user, this procedure will determine what the computer modifier will be and return this value to its caller (2 marks). | 2 marks |
generateLuckySum | function | ageModifier (integer): genderModifier (integer): computerModifier(integer)
|
luckySum (integer) | This function will return the sum of the three parameters (the three modifiers). | 2 marks |
generateLuckyNumber | function | luckySum (integer) | luckyNumber(integer) | Based on the luckySum parameter this function will determine and return the user's lucky number back to its caller. | 2 marks |
displayLuckyNumber | procedure | luckyNumber (integer) | NA | Displays the user's lucky number | 1 mark |
Finally if you can use the pre-created function UpCase to convert any lower case character input entered by the user (for the gender, computer type and prompt to re-run the program) to upper case values (so that you're program can handle upper or lower case input) you receive an extra 4 marks.
To help you visualize the structure of your program I've included a diagram that shows the hierarchy of calls for the modules:
To help make sure that you haven't missed anything here is a checklist of items to be used in marking. A sample executable 'lucky' can be found in UNIX under the directory: /home/231/tamj/assignments/assignment5. Also there will be a skeleton program called 'lucky.p' that you must use as the starting point for your own program.