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 the problem. Conduct research. Ask questions as needed. Think "OK, I can do this - I can solve this problem!
- Step Two: 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 Three: Determine your 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.
- Step Four: 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: Based on the goals of the program, determine and document (list) meaningful names of the program (class, method, or function-python).
- Step Six: 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: 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:[IF YOU ARE NOT SURE WHAT SHOULD BE YOUR VARIABLES, COMPLETE THIS STEP] 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: 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: 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.
Ask for number of test scores
Store response in totalScores
REPEAT (do the following until all test scores have been enetred):
*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: STEP ELEVEN should only be implemented if you are creating functions (python) or methods (java). Highlight (underline, circle, bold) the actions (action words / verbs) in your pseudo code.
- Step Twelve: 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 using title sentences in each method. Then build out the complexity of each, one at a time.)
- Step Thirteen: Translate your pseudocode (description of each step) into code, line by line, using your desired language.
- Step Fourteen: 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 and debug your code using the examples you created in STEP SIX. Use them to design your Unit Tests, if you have reached this concept in your programming course.
- Step Sixteen: 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.