Java Reference
In-Depth Information
with business experts who have the necessary subject matter expertise. Even if you are programming
for yourself, taking the time upfront to consider all the demands you want your program to meet will
limit the amount of changes required later in the process. At the end of this step, it is important to know
what the input to the program will receive and what output it should give. In the BMI example, you will
need to know whether the height will be measured in meters or feet and the weight in kilos or pounds.
You would also want to determine whether the output should be just the BMI results or also a message
stating whether or not the person is overweight.
Once you have a thorough understanding of the business problem, you can start thinking about
ways to solve it using a computer program. In other words, which processing steps should take
place on the input(s) in order to give the desired output(s)? The procedure needed to solve the
problem is also often referred to as the algorithm . When working out an algorithm, common sense
and creativity both play an important role. A first useful step in designing an algorithm is plan-
ning the application logic using pseudo-code or flowcharts. Pseudo-code is a type of structured
English but without strict grammar rules. It is a user-friendly way of representing application
logic in a sequential, readable format. It allows the problem statement to be broken into manage-
able pieces in order to reduce its complexity. Following is an example of pseudo-code for the BMI
case. A flowchart represents the application in a diagram, whereby the boxes show the activities
and the arrows the sequences between them. Table 1-1 presents an overview of the most important
flowchart construction concepts. Figure 1-3 then gives an example of a flowchart for the BMI case.
Both pseudo-code and flowcharts can be used concurrently to facilitate the programming exercise.
A key advantage of flowcharts when compared to pseudo-code is that they are visual and thus
easier to interpret.
ask user: height
ask user: weight
if height = 0 or weight = 0:
error: "Incorrect input values"
return to beginning (ask height and weight)
end if
x = weight / (height * height)
message: "Your BMI is ",x
Table 1-1 is an overview of the most important flowchart modeling concepts.
tableĀ 1-1: Key Flowchart Modeling Concepts
floWchart symbol
meaning
A terminator shows the start and stopping points of
the program.
An arrow shows the direction of the process flow.
A rectangle represents a process step or activity.
continues
Search WWH ::




Custom Search