Understanding the Problem

When the programmer is faced with a problem to solve, the problem must be read carefully and maybe, read a number of times to be very sure that the problem is understood. It is advisable to delete all unnecessary information given in the problem statement. Example: Calculate the floor area of the boardroom that is on the second floor of the building next to the road to FUT Minna. The length of the room is 7 meters and the width is 4 meters. It is the largest room on the second floor. This problem statement can be simplified by deleting the unnecessary information as follows:

Calculate the floor area of the boardroom that is on the second floor of the building next to the road to FUT MInna. The length of the room is 7 meters and the width is 4 meters. It is the largest room on the second floor.

The problem statement is now much easier to read and understand: Calculate the floor area of the board room. The length of the room is 7 meters and the width is 4 meters.

The problem statement must include enough information to enable the programmer to solve the problem. But, if some data (values) are missing, it must be of such a kind that the user will be able to supply the missing data.

Example: The sum of 2 numbers must be calculated.

The problem statement does not supply the values of the numbers, but the algorithm can ask the user to supply the value of the numbers. The most important aspect of solving a problem by using a computer is to write an algorithm to solve it. An algorithm is a set of steps that must be written in such a way that is it unambiguous and precise. The computer cannot think for itself, you as the programmer must tell the computer exactly what to do. You may never assume that the computer will do something if you have not explicitly included the specific step.

Data Processing

An algorithm to solve a computer-based problem consists of 3 phases’ i.e.

  • What you have available for the algorithm to solve the problem
  • How you are going to solve the problem i.e. what steps you are going to take
  • What is the required result

Schematically it can be shown as follows (Figure 1-1):


Each of the figures above clearly indicates that the algorithm must receive data (input) that must be processed to render meaningful results (output or information). In other words:

  • Input is processed to render meaningful output.
  • Data is processed to render meaningful information

Example:

The manager of a company asks a student to do some part time work for which he will be paid per hour. The student will have to know how many hours he has to work at what rate of pay before he can calculate the final amount he will receive.

In this case the input (data) to this algorithm will be the hours and the hourly rate of pay. The input (data) must be processed to give the output (information) i.e. the amount the student will receive. It is clear that the input (data) is meaningless unless it is processed, because if the student knows how much he will receive per hour, but does not know how many hours he will work, the pay cannot be calculated! On the other hand, if the student has worked for 20 hours but the manager does not tell him how much he will receive per hour, it is also meaningless. Now it is possible to formulate the following:

  • Unprocessed data is meaningless.
  • Information is processed data.
  • Output is processed data or processed input

Problem: Calculate the sum of 2 numbers and display the result on the screen:

Input: Not available in the problem statement. The user has to supply the numbers.

Processing: Add the 2 numbers to determine the sum.

Output: The sum as calculated in the processing phase is displayed on the screen of the computer. Note the following:

  • The value of the numbers must be available before the sum can be calculated.
  • It is impossible to display the sum before it has been calculated.

These two remarks indicate that the steps must always be processed in a logical order.