Skip to content

Latest commit

 

History

History
62 lines (40 loc) · 2.11 KB

exercise5a.md

File metadata and controls

62 lines (40 loc) · 2.11 KB

Exercise 5 a (Analysis of a problem)

In this exercise, we shall look into the creation of a solution to a given problem. Let us assume a very basic problem to do with. We will analyse and design an algorithm for the solution.

Sample problem

'''
In a test of five students, the marks, 40, 78, 91, 59 and 12 were obtained.
If the test score was over 100. Find the:

    1. sum of the scores obtained by the student
    2. average of the score
    3. number of students who scored above the average score
    4. number of students who scored below the average score

'''

Analysis

To analyse the sample problem above, there are three things we need to look out for in the given problem. These are:

  1. the input
  2. the output
  3. the process

The input

This is simply the parameters that are given in the problem, and for the above problem, they are:

  1. the total number of students, which is five.
  2. the individual scores, which are 40, 78, 91, 59 and 12.
  3. the overall score, which is 100.

The output

This is what the program is expected to do - the expected outcome, what the user would see, finally after the process. Usually, we look at the process ( calculations before the output). We are expected to compute the values for the:

  1. sum of the scores
  2. average of the scores
  3. number of students who scored above the average score
  4. number of students who scored below the average score

Note

Usually, the desired output dictates how to compute on the input to obtain the output.

The process

From the problem, we are to compute the sum of the scores and the others. Our focus here is to find how to achieve the output. Most often, there would be a straight forward formula to use, other than that we have to find it. So now, all we have to think about is how to compute the :

  1. sum of the scores
  2. average of the scores
  3. number of students who scored above the average score
  4. number of students who scored below the average score

Note

The result from the computation is what becomes our output though not all becomes the output.

continuation in exercise 5 b (Design of a solution)