The steps are listed below in text form. You may also use the interactive forms linked above. These steps are useful regardless of your selected programming language or IDE (integrated development environment).
- Step One: Understand and document your understanding of the problem. Conduct research. Ask questions as needed. Make a list of all your questions. Document all that you know and all that you want to know. Also document all that your code must accomplish. These tasks can be considered your REQUIREMENTS. An example of this might be what your code must do for input validation. Think "OK, I can do this - I can solve this problem!
- Step Two: Create your plan. Determine your manual solution. Use what you know or have learned to create a plan/strategy for the solution. Think like a computer and determine what you would need to do from the first step to the last step in order to have a working program. Result: Determine and document your inputs, your calculations, and your outputs. Use these to perform the next step.
- Step Three: Write the purpose statement. Write the purpose statement for the program (class, method, or function) indicating the exact input, the exact output, and details about the procedure used to solve to get the output.
The purpose of this program is to consume the number of test scores to be entered as well as all the test scores and produce a list of test scores along with the average test score by adding all the test scores and dividing the sum by the total number of test scores.
- Step Four: Document your assumptions. Think of and document your assumptions for this program, class, method, or function. Remember to list these as comments in your code.
Assumptions: All test scores will be positive integers.
- Step Five: List all meaningful identifiers. Based on the goals of the program, determine and document (list) meaningful names of the program (class, method, or function-python).
- Step Six: Illustrate everything you would see on the screen (what happens when you run your code). Based on your idea for the solution in STEP THREE, Describe, list, draw, or write exactly how you envision the final program to look when it is successfully run. Include instructions, each prompt, user response, and output.
INSTRUCTIONS: Please enter the number of test scores when asked. Then enter each test score until you have reached the end of the list of scores. This program will then display the list of test scores and their average.
How many test scores will you enter? 3
Please enter each test score:
The average of the 3 test scores you entered (100, 100, 100) is 100.
- Step Seven: Document examples as tests. Think of and document at least 3 examples of input and corresponding output when run successfully.
EX1: 3 => 100 100 100 => 100 + 100 + 100 = 300 => 300/3 = 100
EX2: 4 => 90 95 80 75 => 90 + 95 + 80 +75 = 340 => 340/4 = 85
EX3: 5 => 50 76 88 97 105 => 50 + 76 + 88 + 97 + 105 = 416 => 416/5 = 83.2
- Step Eight: Create your variables. [ONLY COMPLETE THIS STEP IF YOU ARE LEARNING ABOUT VARIABLE AND NEED HELP] Make note of what changes from example to example and use these data to determine which are variables and which meaning variable names you'd like to use for them. Remember to use the camelcase naming convention.
Going from example to example, the following changes: 1) total number of scores to be entered, 2) the actual scores, 3) the sum, and 4) the average.
Therefore, possible variable names to use are: totalScores, score1, score2, score3, and so on, sum, and average.
- Step Nine: Decompose your solution line by line in english. Based on your idea for the solution in STEP THREE, list the steps your program should perform, one at a time (one action per line), in order from start to finish for a successful solution. You can use the variable names just created in STEP SEVEN.
1. Ask the user for the number of test scores
2. Save user input into a variable called totalScores
3. Add all the test scores
4. Save total in the variable called sum
5. Divide sum by number of test scores
6. Save the result in the variable called average
7. Print the result.
- Step Ten: Create your pseudocode. Going line by line from your description in STEP EIGHT, write how each step will be implemented using programming constructs (e.g. if-then, loops, etc.). This is your pseudo-code.
See these links for guidance:
Ask for number of test scores
Store response in totalScores
REPEAT (do the following until all test scores have been entered):
*Accept test score
*Store entered score in score#
END REPEAT Add all test scores
Store total in variable sum
Divide the sum by the number of test scores (sum/totalScores)
Store result in average
Display the result
Example Display: The average of 3 test scores (100, 100, 100) is 100.
- Step Eleven: Highlight the verbs in your pseudocode. Highlight (underline, circle, bold) the actions (action words / verbs) in your pseudo code. This will help you determine which methods you should create. You can underling them, change them to a different color, etc. STEP ELEVEN should only be implemented if you are creating functions (python) or methods (java).
- Step Twelve: Use the Prototype Development Approach to code your methods. STEP TWELVE should only be implemented if you are creating functions (python) or methods (java).
Create METHODS/FUNCTIONS using your action words as method names using the PROTOTYPE DEVELOPMENT APPROACH (build methods progressively starting with simply printing the name of the methods to ensure you have accounting for every aspect of your code. Then build out the complexity of each method, one at a time.)
- Step Thirteen: Write code. Translate your pseudocode (description of each step) into code, line by line, using your desired language.
- Step Fourteen: Comment your code. Do this as you are coding, whenever you can. Do not wait until you have finished coding to add comments. But, you should review your comments when you are done to ensure they are correct. Insert your steps and pseudo code from STEPS EIGHT & NINE as comments (e.g. When programming in Java, use documentation comments
, multi-line comments, and single-line comments). Think of this as tagging your code.
- Step Fifteen: Test your code. Test and debug your code using the examples you created in STEP SEVEN. Use them to design your Unit Tests, if you have reached this concept in your programming course.
- Step Sixteen: Document your test results and submit. Document each and every test result and submit these along with your code to firstname.lastname@example.org for class assignments and to email@example.com if you are participating in the Coding Challenge.