Java Reference
In-Depth Information
3. Click the OK button.
The message box showing the user the Body Mass Index is displayed
(Figure 3-35). The calculated BMI value displayed should be 23, the same
value calculated by the previous version of the program.
Close
button
message box
body mass
index displays
OK button
FIGURE 3-35
OTHER WAYS
4. Click the OK button and then click the Close button in the command
prompt window title bar.
The program terminates and the TextPad window again is displayed.
1. Press CTRL + 2 , enter
data at prompts
2. At command
prompt, type java
BodyMassSwing ,
enter data at
prompts
Interactive programs allow programmers the flexibility of testing the
program by running it many times using various sets of sample data, without
having to recompile. As users begin using the program and entering the data,
many things could go wrong, such as entering incorrect information or unrealis-
tic data. This chapter does not attempt to account for all of the possible errors
that might occur; errors and exception handling are covered in more detail in
later chapters. If, however, the program is run with data that makes sense, and
the data is entered correctly, the correct answer will display.
Once you have determined that the program runs correctly, you should print
a copy of the BodyMassSwing source code for documentation purposes. You can
print a copy of the program code from the TextPad coding window by using the
Print command on the File menu. A printout of the program code will be sent to
the default printer. Figure 3-36 on the next page shows the printout of the pro-
gram code for the Swing version of the Body Mass Index Calculator. As shown in
Figure 3-36, long lines of code sometimes wrap to the next line on hard copies.
Your printout may not display line numbers. To print line numbers, see
Appendix C, pages APP 50 through APP 52.
 
Search WWH ::




Custom Search