Java Reference
In-Depth Information
A formula is a mathematical sentence that contains values and operators.
As stated in the requirements document in Figure 3-2 on the previous page, the
Body Mass Index Calculator program must use the following formulas:
meters = inches / 39.36
kilograms = pounds / 2.2
to convert pounds and inches to the metric measurements of meters and
kilograms, respectively. The converted values then are used in the following
formula:
index = kilograms / meters 2
to calculate the BMI.
As noted on the previous page, the formulas require two inputs. The first
formula divides the first input, inches, by 39.36 to calculate meters. The second
formula divides the second input, pounds, by 2.2 to calculate kilograms. The
program then uses the converted values in a third formula, which divides kilo-
grams by the square of the meters to produce the output value for body mass
index. In the third formula, the word, index, represents the body mass index
value. Figure 3-3 displays a list of inputs and outputs, as well as sample data.
INPUTS AND OUTPUTS
INPUTS
OUTPUTS
inches
body mass index
pounds
SAMPLE DATA
INPUTS
OUTPUTS
67 inches
23
145 pounds
62 inches
20
110 pounds
72 inches
27
200 pounds
FIGURE 3-3
DESIGN THE SOLUTION Once you have analyzed the problem, the next step
is to design the user interface. There are three versions of the Body Mass Index
Calculator program with three different kinds of interfaces: (1) a console appli-
cation with prompts at the command line; (2) a console application with dialog
box prompts; and (3) an applet with windowed input and output controls.
Figure 3-4a shows a storyboard for the Body Mass Index Calculator as a con-
sole application. As stated in the requirements document, the program will display
the title, THE SUN FITNESS CENTER BODY MASS INDEX CALCULATOR, at
 
Search WWH ::




Custom Search