Java Reference
In-Depth Information
Figure 1-14 shows a flowchart that represents the algorithm used by the
getShipping() method to calculate the correct shipping charge. The flowchart
includes a control structure , which is a portion of a program that allows the
programmer to specify that code will be executed only if a condition is met. The
control structure in the flowchart, for instance, illustrates how the program
decides which shipping rate to use based on the total shipment weight. The
breakdown of control structures into sequence, selection, and repetition control
structures is explained in detail in Appendix A.
terminal symbol
indicates beginning
g e tShipping()
Method
Begin
input/output
symbol
Get Weight
in Ounces
annotation
symbol
decision symbol
Yes
No
Ounces > 16?
control
structure
Shipping = 12.95 +
((Ounces-16) ? .30)
process
symbol
Shipping = 12.95
flowline symbol
terminal symbol
indicates end
End
FIGURE 1-14
PSEUDOCODE Some programmers use pseudocode to list the actions a
computer should perform and to assist in developing the program logic.
Pseudocode expresses computer actions using keywords and depicts logical
groupings or structures using indentation. Figure 1-15 shows the pseudocode for
the getShipping() method of the Shipment object. The pseudocode is not pro-
gram code but an English representation of how the code should be written. The
pseudocode serves as an intermediary between the requirements and the final
program code.
 
Search WWH ::




Custom Search