Lets begin with problem we will break down for the rest of this segment
Observations about the program:
- The program must pocess 10 test results. We’ll use a for statement and the range function to control iteration
- Each test result is a number - either 1 or a 2. Each time the program reads a test result, the program must determine if the number is a 1 or a 2. We test for a 1 in our algorithm. If the number is not a 1, we assume that it’s a 2
- We’ll use 2 counters - one to count the number of students who passed the exam and one to count the number of students who failed
- After the script processes all the results, it must decide if more than 8 students passed the exam so that it can bonus the instructor
Based on the following pseudocode, what would be our first refinement?
Analyze exam results and decide wether instructor should receive a bonus
Initialize variables
Input the ten exam grades and count passes and failures
Summarize the exam results and decide whether instructor should receive a bonus
Based on our first refinement:
Initialize variables
Input the ten exam grades and count passes and failures
Summarize the exam results and decide whether instructor should receive a bonus
What should be our second refinement? (part 1)
Initialize passes to zero
Initialize failures to zero
Based on our first refinement:
Initialize variables
Input the ten exam grades and count passes and failures
Summarize the exam results and decide whether instructor should receive a bonus
What should be our second refinement? (part 2)
For each of the ten students
…Input the next exam result
…If the student passed
……Add one to passes
…Else
……Add one to failures
Pretend the periods are indentations
Based on our first refinement:
Initialize variables
Input the ten exam grades and count passes and failures
Summarize the exam results and decide whether instructor should receive a bonus
What should be our second refinement? (part 3)
Display the number of passes
Display the number of failures
If more than 8 students passed
…Display “Bonus to instructor”
What would be our complete pseudocode algorithm now with everything together?
What would be the actual algorithm with everything together?