Premise:Just like the algorithm that determines the minimum and maximum scores (example five and example eight), in this example will be combining the two examples here while removing and adding some steps where necessary. Observe what the question says; ...n different scores and...; what do you think?
I was confused when I first approached this question, in fact my algorithm produce a different algorithm that should have a different question. It is Ezeh Maduabuchi a final year student of Economics University of Nigeria, Nsukka, UNN, that actually explained to me what the question means. He says that; "...n different scores... should be n different sets of scores, explaining that it is different groups of scores and I agree with him because the question required that I should calculate the Total (sum) of the minimum and maximum scores. If the scores are just one set/group, then no need of calculating the total (sum) of the minimum and the maximum scores as there will be just only one minimum score and maximum score from that one group of scores.
Solution:
Major Steps
1. Request Data
2. Determine Minimum and Maximum score(s)
4. Display the sum of the minimum and that of the Maximum score
Stepwise Refinement
1. Request Data
1.1 Request numberOfSetsOfScores
1.2 count1 = 0
1.3 TotalMinimum = 0
1.4 TotalMaximum = 0
1.5 Request n
2. Determine Minimum and Maximum score(s)
2.1 count = 0
2.2 Request score
2.3 count1 = count1 + 1
2.4 minimum = score
2.5 Maximum = score
2.6 count = count + 1
2.7 Request score
2.8 If score < Minimum THEN
2.8.1 Minimum = score
Else
2.8.2 Do nothing
2.9 If score > Maximum THEN
2.9.1 Maximum = Score
Else
2.9.2 Do nothing
3.0 Repeat 2.6 - 2.9 until count < n
3.1 TotalMinimum = TotalMinimum + Minimum
3.2 TotalMaximum = TotalMaximum + Maximum
3.3 Repeat 1.5 - 3.2 unitl count1 < numberOfSetsOfScore
4. Display the sum of the minimum and that of the Maximum set of scores
4.1 Display TotalMinimum, TotalMaximum
1. Request Data
2. Determine Minimum and Maximum score(s)
4. Display the sum of the minimum and that of the Maximum score
Stepwise Refinement
1. Request Data
1.1 Request numberOfSetsOfScores
1.2 count1 = 0
1.3 TotalMinimum = 0
1.4 TotalMaximum = 0
1.5 Request n
2. Determine Minimum and Maximum score(s)
2.1 count = 0
2.2 Request score
2.3 count1 = count1 + 1
2.4 minimum = score
2.5 Maximum = score
2.6 count = count + 1
2.7 Request score
2.8 If score < Minimum THEN
2.8.1 Minimum = score
Else
2.8.2 Do nothing
2.9 If score > Maximum THEN
2.9.1 Maximum = Score
Else
2.9.2 Do nothing
3.0 Repeat 2.6 - 2.9 until count < n
3.1 TotalMinimum = TotalMinimum + Minimum
3.2 TotalMaximum = TotalMaximum + Maximum
3.3 Repeat 1.5 - 3.2 unitl count1 < numberOfSetsOfScore
4. Display the sum of the minimum and that of the Maximum set of scores
4.1 Display TotalMinimum, TotalMaximum
Explanation:I believed that you are familiar with all the lines, only what should be new to you are line 1.1, 1.2, 2.3, 3.0, 3.1, 3.2 and line 3.3.
Line 1.1 is the variable that will hold/keep the sets/groups of scores, i named the variable numberOfSetsOfScores just for easy understand if not what I had named the variable somewhere was numOfSet.
Line 1.2, count1 is a variable that I will be using to count a different process or operation.
Line 2.3 just like line 2.6, increases when operation falls to it position. But here it will be counting the numbers of sets/groups of scores that has being entered/requested.
Example: If we will have four (4) groups of scores like:
A = {2, 1, 5, 3},Then count1 will count from zero (0) to four (4), counting A, B, C, D as 0, 1, 2, 3 respectively and that is 4 groups or sets of scores.
B = {7, 9, 10, 4, 1, 23}
C = {4, 50, 11}
D = {8, 32, 3, 6, 2, 8, 4}
Unlike other example, in line 3.0 I changed the format instead of listing the steps to be repeated and separating them with comma; ','; I decides to use hyphen; '-'; to indicate symbolise, "to". Therefore 2.6 - 2.9 is same as writing 2.6 to 2.9 and same as 2.6, 2.7, 2.8 and 2.9. This also is applied to line 3.3. However, line 3.3 tells the algorithm when the desired groups of scores has being exhausted.
Study example ten, line 3.1 and 3.2 is just the application.
So A, B, C and D are n different scores because in
A we have n different scores, where n = 4,Their minimum are 1, 1, 4 and 2 respectively and their maximum are 5, 23, 50 and 32. so using the above minimum and maximum scores line 3.1 and 3.2 should be
B we have n different scores, where n = 6
C; n = 3 and
D; n = 7.
TotalMinimum = 0 + 1 + 1 + 4 + 2 = 8.Step 4.1 will display 8 and 110.
TotalMaximum = 0 + 5 + 23 + 50 + 32 = 110.
As you should have known, all the examples have real life scenarios/applications. For instance the above question can be modified in real life to be:
You are a panel in a certain quiz/competition that comprises of different students/staff from universities, departments or organizations. Write an algorithm that will request for an integer number, n (i.e. number of students in each university or department that are participating in the quiz), afterwards it will request for n different scores (i.e. different scores for each of the students/staff in each of the universities/departments) and it will calculate and display the total of the minimum and maximum scores (i.e. total of the minimum and maximum scores of each of the students/staff in the various universities/departments/organizations)?
So if the universities/departments/organizations are represented as A, B, C and D, then the following universities may be an example respectively:
Massachusetts Institute of Technology, MIT,It therefore mean that their minimum and maximum scores respectively are:
University of California Los Angelis, UCLA,
University of Nigeria, Nsukka, UNN, and
Oxford University.
Minimum Scores: 1, 1, 4 and 2.
Maximum Scores: 5, 23, 50 and 32.
SHARE THIS POST WITH YOUR FRIENDS...::
Tweet
0 comments:
Leave a Reply