Premise:The problem above requires us to partially combine example nine and example ten.
Solution:
Major Steps
1. Request Data
2. Calculate Product, Sum
4. Display Product, sum
Stepwise Refinement
1. Request Data
1.1 Request n
2. Determine Summation of Product and Sum
2.1 Product = 1
2.2 sum = 0
2.3 count = 0
2.4 SumOfProd&sum = 0
2.5 count = count + 1
2.6 Request Xi
2.7 Product = product * Xi
2.8 sum = sum + Xi
2.9 Repeat 2.5, 2.6, 2.7 and 2.8 until count < n
3.0 SumOfProd&sum = SumOfProd&sum + (product + sum)
4. Display SumOfProd&sum
1. Request Data
2. Calculate Product, Sum
4. Display Product, sum
Stepwise Refinement
1. Request Data
1.1 Request n
2. Determine Summation of Product and Sum
2.1 Product = 1
2.2 sum = 0
2.3 count = 0
2.4 SumOfProd&sum = 0
2.5 count = count + 1
2.6 Request Xi
2.7 Product = product * Xi
2.8 sum = sum + Xi
2.9 Repeat 2.5, 2.6, 2.7 and 2.8 until count < n
3.0 SumOfProd&sum = SumOfProd&sum + (product + sum)
4. Display SumOfProd&sum
Explanation:I observe that the major steps is not like other previous examples and also these is the first time we encounter a line of step below/after repeat step; line 3.0. In the major steps, I jumped the number three (3) because steps 2 extend to 3.0 this is based on my own numbering convection. You can adapt yours but make sure it does not confuse you or your algorithm. You can even use an alphabets as the major steps and sub steps can be Roman figures and still if you like you can number the steps with normal integers only instead of the numbering convection am using here.
Line 3.0 say SumOfprod&sum, the variable SumOfprod&sum is the summation of the Products and the Sum of the numbers, Xi, as required by the equation above. For explanation check example nine and example ten, line 3.0 in this example is just the different.
SHARE THIS POST WITH YOUR FRIENDS...::
Tweet
0 comments:
Leave a Reply